From bc14401314d5e0510e4637350f137ecac02e0d7e Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:19:07 +0500 Subject: [PATCH 01/40] Updated NewPlatform.Flexberry.ORM Up to 7.2.0-alpha01 --- .../NewPlatform.Flexberry.ORM.ODataService.Files.csproj | 2 +- .../NewPlatform.Flexberry.ORM.ODataService.WebApi.csproj | 2 +- .../NewPlatform.Flexberry.ORM.ODataService.csproj | 2 +- ...wPlatform.Flexberry.ORM.ODataServiceCore.Common.csproj | 2 +- ...lexberry.ORM.ODataService.Tests.BusinessServers.csproj | 8 ++++---- .../NewPlatform.Flexberry.ORM.ODataService.Tests.csproj | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/NewPlatform.Flexberry.ORM.ODataService.Files/NewPlatform.Flexberry.ORM.ODataService.Files.csproj b/NewPlatform.Flexberry.ORM.ODataService.Files/NewPlatform.Flexberry.ORM.ODataService.Files.csproj index 0efac5ca..47449e37 100644 --- a/NewPlatform.Flexberry.ORM.ODataService.Files/NewPlatform.Flexberry.ORM.ODataService.Files.csproj +++ b/NewPlatform.Flexberry.ORM.ODataService.Files/NewPlatform.Flexberry.ORM.ODataService.Files.csproj @@ -21,7 +21,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/NewPlatform.Flexberry.ORM.ODataService.WebApi/NewPlatform.Flexberry.ORM.ODataService.WebApi.csproj b/NewPlatform.Flexberry.ORM.ODataService.WebApi/NewPlatform.Flexberry.ORM.ODataService.WebApi.csproj index 7f2c41cd..812d2d61 100644 --- a/NewPlatform.Flexberry.ORM.ODataService.WebApi/NewPlatform.Flexberry.ORM.ODataService.WebApi.csproj +++ b/NewPlatform.Flexberry.ORM.ODataService.WebApi/NewPlatform.Flexberry.ORM.ODataService.WebApi.csproj @@ -22,7 +22,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/NewPlatform.Flexberry.ORM.ODataService/NewPlatform.Flexberry.ORM.ODataService.csproj b/NewPlatform.Flexberry.ORM.ODataService/NewPlatform.Flexberry.ORM.ODataService.csproj index a80cce2d..f3ce59a1 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/NewPlatform.Flexberry.ORM.ODataService.csproj +++ b/NewPlatform.Flexberry.ORM.ODataService/NewPlatform.Flexberry.ORM.ODataService.csproj @@ -26,7 +26,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/NewPlatform.Flexberry.ORM.ODataServiceCore.Common/NewPlatform.Flexberry.ORM.ODataServiceCore.Common.csproj b/NewPlatform.Flexberry.ORM.ODataServiceCore.Common/NewPlatform.Flexberry.ORM.ODataServiceCore.Common.csproj index 104e7d0a..34f09c3e 100644 --- a/NewPlatform.Flexberry.ORM.ODataServiceCore.Common/NewPlatform.Flexberry.ORM.ODataServiceCore.Common.csproj +++ b/NewPlatform.Flexberry.ORM.ODataServiceCore.Common/NewPlatform.Flexberry.ORM.ODataServiceCore.Common.csproj @@ -26,7 +26,7 @@ - + diff --git a/Tests/BusinessServers/NewPlatform.Flexberry.ORM.ODataService.Tests.BusinessServers.csproj b/Tests/BusinessServers/NewPlatform.Flexberry.ORM.ODataService.Tests.BusinessServers.csproj index 376e1dc8..ce2bba56 100644 --- a/Tests/BusinessServers/NewPlatform.Flexberry.ORM.ODataService.Tests.BusinessServers.csproj +++ b/Tests/BusinessServers/NewPlatform.Flexberry.ORM.ODataService.Tests.BusinessServers.csproj @@ -14,10 +14,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/NewPlatform.Flexberry.ORM.ODataService.Tests.csproj b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/NewPlatform.Flexberry.ORM.ODataService.Tests.csproj index 6b7d0970..e14d37d9 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/NewPlatform.Flexberry.ORM.ODataService.Tests.csproj +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/NewPlatform.Flexberry.ORM.ODataService.Tests.csproj @@ -40,9 +40,9 @@ - - - + + + From bf342f7eff40bd797e8994497cff803b5253e886 Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:25:37 +0500 Subject: [PATCH 02/40] Fast fixes for project building after ORM update --- .../Offline/DefaultOfflineManager.cs | 12 ++-- .../Offline/OfflineAuditService.cs | 16 ++++- .../BaseIntegratedTest.cs | 27 +++++--- .../CRUD/MultiThreadTests.cs | 62 +++++++++++-------- .../Http/WebHttpUser.cs | 7 +-- .../DefaultOfflineManagerIntegratedTest.cs | 21 ++++--- .../OfflineAuditServiceIntegratedTest.cs | 10 +-- .../Startup.cs | 11 ++-- .../XUnitTestRunnerInitializer.cs | 11 ++++ ...erry.ORM.ODataService.Tests.Objects.csproj | 8 +-- 10 files changed, 118 insertions(+), 67 deletions(-) diff --git a/NewPlatform.Flexberry.ORM.ODataService/Offline/DefaultOfflineManager.cs b/NewPlatform.Flexberry.ORM.ODataService/Offline/DefaultOfflineManager.cs index 7c186c94..eea2c873 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Offline/DefaultOfflineManager.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Offline/DefaultOfflineManager.cs @@ -4,20 +4,18 @@ using System.Collections.Generic; using System.Linq; - using ICSSoft.Services; - using ICSSoft.STORMNET; - - using Microsoft.AspNet.OData.Query; - + using ICSSoft.STORMNET; + using Microsoft.AspNet.OData.Query; + using NewPlatform.Flexberry.ORM.CurrentUserService; using NewPlatform.Flexberry.Services; public class DefaultOfflineManager : BaseOfflineManager { private readonly ILockService _lockService; - private readonly CurrentUserService.IUser _currentUser; + private readonly ICurrentUser _currentUser; - public DefaultOfflineManager(ILockService lockService, CurrentUserService.IUser currentUser) + public DefaultOfflineManager(ILockService lockService, ICurrentUser currentUser) { _lockService = lockService ?? throw new ArgumentNullException(nameof(lockService), "Contract assertion not met: lockService != null"); _currentUser = currentUser ?? throw new ArgumentNullException(nameof(currentUser), "Contract assertion not met: currentUser != null"); diff --git a/NewPlatform.Flexberry.ORM.ODataService/Offline/OfflineAuditService.cs b/NewPlatform.Flexberry.ORM.ODataService/Offline/OfflineAuditService.cs index 11a3c773..e91c2fbe 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Offline/OfflineAuditService.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Offline/OfflineAuditService.cs @@ -2,8 +2,9 @@ { using System; using ICSSoft.STORMNET; - using ICSSoft.STORMNET.Business.Audit; - + using ICSSoft.STORMNET.Business.Audit; + using NewPlatform.Flexberry.ORM.CurrentUserService; + /// /// Implementation of for offline audit mode. /// Instead of manual setting audit fields () on saving changes, @@ -12,6 +13,17 @@ /// public class OfflineAuditService : AuditService { + /// + /// Initializes a new instance of the class. + /// + /// + /// Сервис доступа к данным текущего пользовтаеля. + /// + public OfflineAuditService(ICurrentUser currentUser) + : base(currentUser) + { + } + /// /// Adds audit information for specified new data object. /// Does nothing in order to preserve data at fields. diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index 22cac7b0..da641b08 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -9,6 +9,9 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using System.Linq; using System.Threading; using ICSSoft.STORMNET.Business; + using ICSSoft.STORMNET.Business.Audit; + using ICSSoft.STORMNET.Security; + using Moq; using Npgsql; using Oracle.ManagedDataAccess.Client; using Xunit; @@ -25,8 +28,8 @@ public abstract class BaseIntegratedTest : IDisposable using Microsoft.AspNetCore.Mvc.Testing; using ODataServiceSample.AspNetCore; using ICSSoft.Services; - using Unity; - + using Unity; + /// /// Base class for integration tests. /// @@ -316,9 +319,13 @@ protected BaseIntegratedTest(CustomWebApplicationFactory factory, ITest /// The instance. protected virtual MSSQLDataService CreateMssqlDataService(string connectionString) { + var securityManager = new EmptySecurityManager(); + var mockAuditService = new Mock(); + if (_useGisDataService) - return new GisMSSQLDataService { CustomizationString = connectionString }; - return new MSSQLDataService { CustomizationString = connectionString }; + return new GisMSSQLDataService(securityManager, mockAuditService.Object) { CustomizationString = connectionString }; + + return new MSSQLDataService(securityManager, mockAuditService.Object) { CustomizationString = connectionString }; } /// @@ -328,9 +335,13 @@ protected virtual MSSQLDataService CreateMssqlDataService(string connectionStrin /// The instance. protected virtual PostgresDataService CreatePostgresDataService(string connectionString) { + var securityManager = new EmptySecurityManager(); + var mockAuditService = new Mock(); + if (_useGisDataService) - return new GisPostgresDataService { CustomizationString = connectionString }; - return new PostgresDataService { CustomizationString = connectionString }; + return new GisPostgresDataService(securityManager, mockAuditService.Object) { CustomizationString = connectionString }; + + return new PostgresDataService(securityManager, mockAuditService.Object) { CustomizationString = connectionString }; } /// @@ -340,7 +351,9 @@ protected virtual PostgresDataService CreatePostgresDataService(string connectio /// The instance. protected virtual OracleDataService CreateOracleDataService(string connectionString) { - return new OracleDataService { CustomizationString = connectionString }; + var securityManager = new EmptySecurityManager(); + var mockAuditService = new Mock(); + return new OracleDataService(securityManager, mockAuditService.Object) { CustomizationString = connectionString }; } /// diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/MultiThreadTests.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/MultiThreadTests.cs index 238df9a2..0c8d09ac 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/MultiThreadTests.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/MultiThreadTests.cs @@ -17,8 +17,8 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests.CRUD using ICSSoft.STORMNET.FunctionalLanguage; using Microsoft.AspNetCore.Http; - using Microsoft.AspNetCore.Mvc.Infrastructure; - + using Microsoft.AspNetCore.Mvc.Infrastructure; + using NewPlatform.Flexberry.ORM.CurrentUserService; using NewPlatform.Flexberry.ORM.ODataService.Tests.Extensions; using NewPlatform.Flexberry.ORM.ODataService.Tests.Helpers; using NewPlatform.Flexberry.ORM.ODataService.Tests.Http; @@ -70,22 +70,25 @@ public void CreateTest() args => { // Arrange. + IUnityContainer container; #if NETFRAMEWORK - RegisterCustomUser(UnityFactory.GetContainer()); + container = UnityFactory.GetContainer(); #elif NETCOREAPP - RegisterCustomUser(args.UnityContainer); + container = args.UnityContainer; #endif + RegisterCustomUser(container); + ICurrentUser currentUser = container.Resolve(); // Регистрация событий. args.Token.Events.CallbackBeforeCreate = dobj => { - string login = CurrentUserService.CurrentUser.Login; + string login = currentUser.Login; return dobj is Страна country && country.Название == login; }; args.Token.Events.CallbackAfterCreate = dobj => { - string login = CurrentUserService.CurrentUser.Login; + string login = currentUser.Login; if (!(dobj is Страна country && country.Название == login)) { throw new Exception("Incorrect data"); @@ -163,13 +166,16 @@ public void UpdateTest() { ActODataService( args => - { - // Arrange. + { + // Arrange. + IUnityContainer container; #if NETFRAMEWORK - RegisterCustomUser(UnityFactory.GetContainer()); + container = UnityFactory.GetContainer(); #elif NETCOREAPP - RegisterCustomUser(args.UnityContainer); + container = args.UnityContainer; #endif + RegisterCustomUser(container); + ICurrentUser currentUser = container.Resolve(); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[ThreadCount]; @@ -183,13 +189,13 @@ public void UpdateTest() // Регистрация событий. args.Token.Events.CallbackBeforeUpdate = dobj => { - string login = CurrentUserService.CurrentUser.Login; + string login = currentUser.Login; return dobj is Страна country && country.Название == login; }; args.Token.Events.CallbackAfterUpdate = dobj => { - string login = CurrentUserService.CurrentUser.Login; + string login = currentUser.Login; if (!(dobj is Страна country && country.Название == login)) { throw new Exception("Incorrect data"); @@ -223,13 +229,16 @@ public void DeleteTest() { ActODataService( args => - { - // Arrange. + { + // Arrange. + IUnityContainer container; #if NETFRAMEWORK - RegisterCustomUser(UnityFactory.GetContainer()); + container = UnityFactory.GetContainer(); #elif NETCOREAPP - RegisterCustomUser(args.UnityContainer); + container = args.UnityContainer; #endif + RegisterCustomUser(container); + ICurrentUser currentUser = container.Resolve(); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[ThreadCount]; @@ -243,7 +252,7 @@ public void DeleteTest() // Регистрация событий. args.Token.Events.CallbackBeforeDelete = dobj => { - string login = CurrentUserService.CurrentUser.Login; + string login = currentUser.Login; // Возьмем объект из эталона. var preparedCountry = countries.FirstOrDefault(x => PKHelper.EQDataObject(dobj, x, true)); @@ -252,7 +261,7 @@ public void DeleteTest() args.Token.Events.CallbackAfterDelete = dobj => { - string login = CurrentUserService.CurrentUser.Login; + string login = currentUser.Login; // Возьмем объект из эталона. var preparedCountry = countries.FirstOrDefault(x => PKHelper.EQDataObject(dobj, x, true)); @@ -289,24 +298,27 @@ public void BatchTest() { ActODataService( args => - { - // Arrange. + { + // Arrange. + IUnityContainer container; #if NETFRAMEWORK - RegisterCustomUser(UnityFactory.GetContainer()); + container = UnityFactory.GetContainer(); #elif NETCOREAPP - RegisterCustomUser(args.UnityContainer); + container = args.UnityContainer; #endif + RegisterCustomUser(container); + ICurrentUser currentUser = container.Resolve(); // Регистрация событий. args.Token.Events.CallbackBeforeUpdate = dobj => { - string login = CurrentUserService.CurrentUser.Login; + string login = currentUser.Login; return dobj is Кошка cat && cat.Кличка == login; }; args.Token.Events.CallbackAfterUpdate = dobj => { - string login = CurrentUserService.CurrentUser.Login; + string login = currentUser.Login; if (!(dobj is Кошка cat && cat.Кличка == login)) { throw new Exception("Incorrect data"); @@ -338,7 +350,7 @@ private static void RegisterCustomUser(IUnityContainer container) #if NETCOREAPP container.RegisterType(); #endif - container.RegisterType(); + container.RegisterType(); } private static void MultiThreadMethodCreate(object sender) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Http/WebHttpUser.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Http/WebHttpUser.cs index 08a8421a..322d7ead 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Http/WebHttpUser.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Http/WebHttpUser.cs @@ -9,15 +9,14 @@ using Microsoft.AspNetCore.Http; #if NETCOREAPP using Microsoft.AspNetCore.Mvc; - using Microsoft.AspNetCore.Mvc.Infrastructure; + using Microsoft.AspNetCore.Mvc.Infrastructure; #endif - - using static ICSSoft.Services.CurrentUserService; + using NewPlatform.Flexberry.ORM.CurrentUserService; /// /// Класс, представляющий текущего аутентифицированного пользователя на основе заголовков. /// - public class WebHttpUser : IUser + public class WebHttpUser : ICurrentUser { private readonly IHttpContextAccessor contextAccessor; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs index 53e435ae..debbe59b 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs @@ -13,8 +13,9 @@ using NewPlatform.Flexberry.ORM.ODataService.Offline; using NewPlatform.Flexberry.ORM.ODataService.Tests.Extensions; - using NewPlatform.Flexberry.Services; - + using NewPlatform.Flexberry.Services; + using NewPlatform.Flexberry.ORM.CurrentUserService; + public class DefaultOfflineManagerIntegratedTest : BaseODataServiceIntegratedTest { #if NETCOREAPP @@ -32,7 +33,7 @@ public void TestAcquiringWithoutLock() ActODataService(args => { var lockService = new LockService(args.DataService); - var currentUser = new Mock().Object; + var currentUser = new Mock().Object; var offlineManager = new DefaultOfflineManager(lockService, currentUser); args.UnityContainer.RegisterInstance(offlineManager); @@ -51,7 +52,7 @@ public void TestAcquiringWithLock() { ActODataService(args => { - var userMock = new Mock(); + var userMock = new Mock(); var lockService = new LockService(args.DataService); var offlineManager = new DefaultOfflineManager(lockService, userMock.Object); args.UnityContainer.RegisterInstance(offlineManager); @@ -72,7 +73,7 @@ public void TestAcquiringLockedObject() { ActODataService(args => { - var userMock = new Mock(); + var userMock = new Mock(); var lockService = new LockService(args.DataService); var offlineManager = new DefaultOfflineManager(lockService, userMock.Object); args.UnityContainer.RegisterInstance(offlineManager); @@ -100,7 +101,7 @@ public void TestUpdateLockedObjectBySameUserWithFlag() { ActODataService(args => { - var userMock = new Mock(); + var userMock = new Mock(); userMock.Setup(u => u.Login).Returns("user1"); var lockService = new LockService(args.DataService); @@ -128,7 +129,7 @@ public void TestUpdateLockedObjectBySameUserWithoutUnlockFlag() { ActODataService(args => { - var userMock = new Mock(); + var userMock = new Mock(); userMock.Setup(u => u.Login).Returns("user1"); var lockService = new LockService(args.DataService); @@ -156,7 +157,7 @@ public void TestUpdateLockedObjectByAnotherUserWithUnlockFlag() { ActODataService(args => { - var userMock = new Mock(); + var userMock = new Mock(); var lockService = new LockService(args.DataService); var offlineManager = new DefaultOfflineManager(lockService, userMock.Object); args.UnityContainer.RegisterInstance(offlineManager); @@ -208,7 +209,7 @@ public void TestUnlockingAfterErrorInLocking() return realLockService.LockObject(key, userName); }); - var userMock = new Mock(); + var userMock = new Mock(); var offlineManager = new DefaultOfflineManager(lockServiceMock.Object, userMock.Object); args.UnityContainer.RegisterInstance(offlineManager); @@ -256,7 +257,7 @@ public void TestLockingAfterErrorInUnlocking() return realLockService.UnlockObject(key); }); - var userMock = new Mock(); + var userMock = new Mock(); var offlineManager = new DefaultOfflineManager(lockServiceMock.Object, userMock.Object); args.UnityContainer.RegisterInstance(offlineManager); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs index 96e4b461..9c9001e1 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs @@ -4,7 +4,9 @@ using ICSSoft.STORMNET.Business; using ICSSoft.STORMNET.Business.Audit; using ICSSoft.STORMNET.Business.Audit.Objects; - using ICSSoft.STORMNET.Security; + using ICSSoft.STORMNET.Security; + using Moq; + using NewPlatform.Flexberry.ORM.CurrentUserService; using NewPlatform.Flexberry.ORM.ODataService.Offline; using Xunit; using Xunit.Abstractions; @@ -131,11 +133,11 @@ protected override PostgresDataService CreatePostgresDataService(string connecti /// Returns instance of the class that will be used for the test. protected AuditService GetAuditServiceForTest() { - return new OfflineAuditService + Mock mockCurrentUser = new Mock(); + return new OfflineAuditService(mockCurrentUser.Object) { AppSetting = new AuditAppSetting { AuditEnabled = true }, - ApplicationMode = AppMode.Win, - Audit = new Audit() + Audit = new EmptyAudit(), }; } } diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs index 0f62ed20..b7a05295 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs @@ -5,7 +5,8 @@ namespace ODataServiceSample.AspNetCore using System.IO; using System.Linq; using ICSSoft.Services; - using ICSSoft.STORMNET.Business; + using ICSSoft.STORMNET.Business; + using ICSSoft.STORMNET.Business.Audit; using ICSSoft.STORMNET.Security; using ICSSoft.STORMNET.Windows.Forms; using IIS.Caseberry.Logging.Objects; @@ -14,7 +15,8 @@ namespace ODataServiceSample.AspNetCore using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using Moq; using NewPlatform.Flexberry.ORM.ODataService.Extensions; using NewPlatform.Flexberry.ORM.ODataService.Files; using NewPlatform.Flexberry.ORM.ODataService.Model; @@ -64,10 +66,11 @@ public virtual void ConfigureServices(IServiceCollection services) { IUnityContainer unityContainer = UnityFactory.GetContainer(); - IDataService dataService = new PostgresDataService() { CustomizationString = CustomizationString }; + var securityManager = new EmptySecurityManager(); + var mockAuditService = new Mock(); + IDataService dataService = new PostgresDataService(securityManager, mockAuditService.Object) { CustomizationString = CustomizationString }; unityContainer.RegisterInstance(dataService); - ExternalLangDef.LanguageDef.DataService = dataService; unityContainer.RegisterInstance(new LockService(dataService)); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs index d0423c4b..36952b33 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs @@ -8,6 +8,12 @@ namespace NewPlatform.Flexberry.ORM.IntegratedTests using System.Reflection; using System.Text; #endif + + using ICSSoft.STORMNET.Business; + using ICSSoft.STORMNET.Business.Audit; + using ICSSoft.STORMNET.Security; + using ICSSoft.STORMNET.Windows.Forms; + using Moq; using Xunit.Abstractions; using Xunit.Sdk; @@ -23,6 +29,11 @@ public class XUnitTestRunnerInitializer : XunitTestFramework public XUnitTestRunnerInitializer(IMessageSink messageSink) : base(messageSink) { + IDataService ds = new MSSQLDataService(new Mock().Object, new Mock().Object); + DataServiceProvider.DataService = ds; + ExternalLangDef.LanguageDef = new ExternalLangDef(ds); + DetailVariableDef.ViewGenerator = null; + #if NETCOREAPP Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); string configFile = $"{Assembly.GetExecutingAssembly().Location}.config"; diff --git a/Tests/Objects/NewPlatform.Flexberry.ORM.ODataService.Tests.Objects.csproj b/Tests/Objects/NewPlatform.Flexberry.ORM.ODataService.Tests.Objects.csproj index 73e0de6a..4d6c7487 100644 --- a/Tests/Objects/NewPlatform.Flexberry.ORM.ODataService.Tests.Objects.csproj +++ b/Tests/Objects/NewPlatform.Flexberry.ORM.ODataService.Tests.Objects.csproj @@ -14,10 +14,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive From 89510de103bfec170ee3df5a74dacdc7ce56ce59 Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:28:21 +0500 Subject: [PATCH 03/40] Fast fixes of unity config after ORM update --- .../Offline/OfflineAuditService.cs | 12 +++---- .../App.config | 31 +++++++++++++++++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/NewPlatform.Flexberry.ORM.ODataService/Offline/OfflineAuditService.cs b/NewPlatform.Flexberry.ORM.ODataService/Offline/OfflineAuditService.cs index e91c2fbe..0f35c0a5 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Offline/OfflineAuditService.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Offline/OfflineAuditService.cs @@ -2,9 +2,9 @@ { using System; using ICSSoft.STORMNET; - using ICSSoft.STORMNET.Business.Audit; - using NewPlatform.Flexberry.ORM.CurrentUserService; - + using ICSSoft.STORMNET.Business.Audit; + using NewPlatform.Flexberry.ORM.CurrentUserService; + /// /// Implementation of for offline audit mode. /// Instead of manual setting audit fields () on saving changes, @@ -14,10 +14,10 @@ public class OfflineAuditService : AuditService { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// - /// Сервис доступа к данным текущего пользовтаеля. + /// + /// Service for approach to data of current user. /// public OfflineAuditService(ICurrentUser currentUser) : base(currentUser) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config index 58ddf418..6add5075 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config @@ -16,8 +16,11 @@ + - + + + - + diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index 5cb0f243..9eb9021b 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -38,7 +38,10 @@ public abstract class BaseIntegratedTest : IClassFixture, IDisp { protected readonly WebApplicationFactory _factory; #endif - protected readonly IUnityContainer _container; + public static IUnityContainer _container; + + public static IServiceProvider _serviceProvider; + /// /// Provider for injection to data services for test purposes. /// @@ -156,7 +159,8 @@ public void Dispose() /// Use DataService with Gis support. protected BaseIntegratedTest(string tempDbNamePrefix, bool useGisDataService = false) { - _container = UnityFactory.GetContainer(); + _container = new UnityContainer(); + _serviceProvider = new UnityServiceProvider(_container); #endif #if NETCOREAPP /// @@ -175,6 +179,7 @@ protected BaseIntegratedTest(TestFixtureData fixtureData, ITestOutputHelper outp _factory = fixtureData.factory; _container = fixtureData.unityContainer; + _serviceProvider = new UnityServiceProvider(_container); _output = output; if (output != null) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index 768fa044..5f71ab81 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -83,16 +83,16 @@ private void Init( bool useNamespaceInEntitySetName = false, PseudoDetailDefinitions pseudoDetailDefinitions = null) { - IUnityContainer unityContainer = new UnityContainer(); - IServiceProvider serviceProvider = new UnityServiceProvider(unityContainer); DataObjectsAssembliesNames = new[] { typeof(Car).Assembly, }; UseNamespaceInEntitySetName = useNamespaceInEntitySetName; - unityContainer.RegisterInstance(null); - _builder = new DefaultDataObjectEdmModelBuilder(DataObjectsAssembliesNames, serviceProvider, UseNamespaceInEntitySetName, pseudoDetailDefinitions); + + + _container.RegisterInstance(null); + _builder = new DefaultDataObjectEdmModelBuilder(DataObjectsAssembliesNames, _serviceProvider, UseNamespaceInEntitySetName, pseudoDetailDefinitions); } /// diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs index 6d625e16..a46607ce 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs @@ -44,7 +44,9 @@ public Startup(IConfiguration configuration) public IConfiguration Configuration { get; } - protected IServiceProvider _serviceProvider; + public static IServiceProvider _serviceProvider; + + public static IUnityContainer _unityContainer; public string CustomizationString => ""; @@ -74,7 +76,7 @@ public virtual void ConfigureServices(IServiceCollection services) Mock mockBusinessServerProvider = new Mock(); IDataService dataService = new PostgresDataService(securityManager, mockAuditService.Object, mockBusinessServerProvider.Object) { CustomizationString = CustomizationString }; - unityContainer.RegisterInstance( + unityContainer.RegisterType( new InjectionConstructor( unityContainer.IsRegistered() ? unityContainer.Resolve() : null, unityContainer.IsRegistered("Export") ? unityContainer.Resolve("Export") : null, @@ -86,6 +88,7 @@ public virtual void ConfigureServices(IServiceCollection services) unityContainer.RegisterInstance(new LockService(dataService)); unityContainer.RegisterInstance(new EmptySecurityManager()); + _unityContainer = unityContainer; _serviceProvider = serviceProvider; services.AddMvcCore(options => diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs index c1bc1cf1..e81b853e 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs @@ -32,7 +32,7 @@ public TestStartup(IConfiguration configuration) /// public override void Configure(IApplicationBuilder app, IHostingEnvironment env) { - IUnityContainer unityContainer = UnityFactory.GetContainer(); + IUnityContainer unityContainer = new UnityContainer(); unityContainer.RegisterInstance(env); app.UseMiddleware(); @@ -45,8 +45,6 @@ public override void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseODataService(builder => { - IUnityContainer container = UnityFactory.GetContainer(); - var assemblies = new[] { typeof(Медведь).Assembly, @@ -55,12 +53,12 @@ public override void Configure(IApplicationBuilder app, IHostingEnvironment env) typeof(Lock).Assembly, }; - PseudoDetailDefinitions pseudoDetailDefinitions = (PseudoDetailDefinitions)container.Resolve(typeof(PseudoDetailDefinitions)); + PseudoDetailDefinitions pseudoDetailDefinitions = (PseudoDetailDefinitions)_serviceProvider.GetService(typeof(PseudoDetailDefinitions)); var modelBuilder = new DefaultDataObjectEdmModelBuilder(assemblies, _serviceProvider, false, pseudoDetailDefinitions); var token = builder.MapDataObjectRoute(modelBuilder); - container.RegisterInstance(typeof(ManagementToken), token); + _unityContainer.RegisterInstance(typeof(ManagementToken), token); }); } } From 5a90da91c3488d78acbdbd55b520838a23289edf Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Fri, 2 Jun 2023 09:27:48 +0500 Subject: [PATCH 19/40] Fixed extra Unity Containers creation --- .../App.config | 302 +++++++++--------- .../BaseIntegratedTest.cs | 19 +- .../BaseODataServiceIntegratedTest.cs | 23 +- .../CRUD/Create/BusinessServersTest.cs | 6 +- .../CRUD/Create/ChangeMasterInBSTest.cs | 6 +- .../CreateWithPseudoDetailDefinedTest.cs | 2 +- .../CRUD/GisCRUDTest.cs | 6 +- .../CRUD/MultiThreadTests.cs | 6 +- .../CRUD/Read/BuiltinQueryFunctionsTest.cs | 6 +- .../CRUD/Read/Excel/ExcelExportTest.cs | 6 +- .../Read/FilterByMasterDetailFieldTest.cs | 6 +- .../CRUD/Read/FilterByMasterFieldTest.cs | 6 +- .../FilterByMasterMasterDetailFieldTest.cs | 6 +- .../Read/FilterByPseudoDetailFieldTest.cs | 4 +- .../CRUD/Read/FilterTest.cs | 6 +- .../CRUD/Read/GetTest.cs | 6 +- .../CRUD/Read/MetaDataTest.cs | 6 +- .../CRUD/Read/ReferenceToMasterTest.cs | 6 +- .../CRUD/Read/SkipTopOrderByTest.cs | 6 +- .../CRUD/Read/UtfRequestsTest.cs | 6 +- .../CRUD/Update/BusinessServersTest.cs | 6 +- .../CRUD/Update/ModifyDataTest.cs | 6 +- .../CRUD/Update/WebFileTest.cs | 6 +- .../CustomWebApplicationFactory.cs | 11 +- .../Events/AfterGetTest.cs | 6 +- .../Events/AfterInternalServerErrorTest.cs | 6 +- .../Events/AfterSaveTest.cs | 6 +- .../Events/BeforeGetTest.cs | 6 +- .../Events/BeforeSaveTest.cs | 6 +- .../Files/FileControllerTest.cs | 4 +- .../Functions/ActionsTest.cs | 6 +- .../Functions/DelegateFunctionsTest.cs | 6 +- .../Functions/FunctionsTest.cs | 6 +- .../Model/CustomizationEdmModelNames.cs | 6 +- .../DefaultOfflineManagerIntegratedTest.cs | 4 +- .../OfflineAuditServiceIntegratedTest.cs | 4 +- .../Startup.cs | 50 ++- .../TestFixtureData.cs | 33 -- .../TestStartup.cs | 21 +- .../XUnitTestRunnerInitializer.cs | 22 +- 40 files changed, 322 insertions(+), 339 deletions(-) delete mode 100644 Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestFixtureData.cs diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config index 1301586a..aa7b5699 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config @@ -1,163 +1,163 @@  - -
-
- - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index 9eb9021b..faead98b 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -29,12 +29,13 @@ public abstract class BaseIntegratedTest : IDisposable #endif #if NETCOREAPP using Microsoft.AspNetCore.Mvc.Testing; - using ODataServiceSample.AspNetCore; + using ODataServiceSample.AspNetCore; + using Microsoft.Practices.Unity.Configuration; /// /// Base class for integration tests. /// - public abstract class BaseIntegratedTest : IClassFixture, IDisposable + public abstract class BaseIntegratedTest : IClassFixture>, IDisposable { protected readonly WebApplicationFactory _factory; #endif @@ -170,16 +171,14 @@ protected BaseIntegratedTest(string tempDbNamePrefix, bool useGisDataService = f /// Unit tests debug output. /// Prefix for temp database name. /// Use DataService with Gis support. - protected BaseIntegratedTest(TestFixtureData fixtureData, ITestOutputHelper output, string tempDbNamePrefix, bool useGisDataService = false) + protected BaseIntegratedTest(CustomWebApplicationFactory factory, ITestOutputHelper output, string tempDbNamePrefix, bool useGisDataService = false) { - if (fixtureData == null) - { - throw new ArgumentNullException(nameof(fixtureData)); - } - - _factory = fixtureData.factory; - _container = fixtureData.unityContainer; + _factory = factory; + _container = new UnityContainer(); + _container.LoadConfiguration(); _serviceProvider = new UnityServiceProvider(_container); + CustomWebApplicationFactory._unityContainer = _container; + _output = output; if (output != null) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index 5f71ab81..7e4be422 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -72,8 +72,8 @@ public BaseODataServiceIntegratedTest( } #endif #if NETCOREAPP - public BaseODataServiceIntegratedTest(TestFixtureData fixtureData, ITestOutputHelper output = null, bool useNamespaceInEntitySetName = false, bool useGisDataService = false, PseudoDetailDefinitions pseudoDetailDefinitions = null) - : base(fixtureData, output, "ODataDB", useGisDataService) + public BaseODataServiceIntegratedTest(CustomWebApplicationFactory factory, ITestOutputHelper output = null, bool useNamespaceInEntitySetName = false, bool useGisDataService = false, PseudoDetailDefinitions pseudoDetailDefinitions = null) + : base(factory, output, "ODataDB", useGisDataService) { Init(useNamespaceInEntitySetName, pseudoDetailDefinitions); } @@ -127,25 +127,25 @@ public virtual void ActODataService(Action action) foreach (IDataService dataService in DataServices) { - using (var container = new UnityContainer()) + //using (var container = new UnityContainer()) using (var config = new HttpConfiguration()) using (var server = new HttpServer(config)) using (var client = new HttpClient(server, false) { BaseAddress = new Uri("http://localhost/odata/") }) { - container.RegisterInstance(dataService); + _container.RegisterInstance(dataService); server.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; config.EnableCors(new EnableCorsAttribute("*", "*", "*")); - config.DependencyResolver = new UnityDependencyResolver(container); + config.DependencyResolver = new UnityDependencyResolver(_container); const string fileControllerPath = "api/File"; config.MapODataServiceFileRoute("File", fileControllerPath); var fileAccessor = new DefaultDataObjectFileAccessor(new Uri("http://localhost/"), fileControllerPath, "Uploads"); - container.RegisterInstance(fileAccessor); + _container.RegisterInstance(fileAccessor); var token = config.MapDataObjectRoute(_builder, server, "odata", "odata", true); token.Events.CallbackAfterInternalServerError = AfterInternalServerError; - var args = new TestArgs { UnityContainer = container, DataService = dataService, HttpClient = client, Token = token }; + var args = new TestArgs { UnityContainer = _container, DataService = dataService, HttpClient = client, Token = token }; action(args); } } @@ -170,14 +170,15 @@ public virtual void ActODataService(Action action) // Add "/odata/" postfix. client.BaseAddress = new Uri(client.BaseAddress, DataObjectRoutingConventions.DefaultRouteName + "/"); - ManagementToken token = (ManagementToken)_container.Resolve(typeof(ManagementToken)); - _container.RegisterInstance(dataService); + IUnityContainer container = TestStartup._unityContainer; // При создании odata-приложения оригинальный контейнер не изменяется. + ManagementToken token = (ManagementToken)container.Resolve(typeof(ManagementToken)); + container.RegisterInstance(dataService); token.Events.CallbackAfterInternalServerError = AfterInternalServerError; var fileAccessor = (IDataObjectFileAccessor)_factory.Services.GetService(typeof(IDataObjectFileAccessor)); - _container.RegisterInstance(fileAccessor); + container.RegisterInstance(fileAccessor); - var args = new TestArgs { UnityContainer = _container, DataService = dataService, HttpClient = client, Token = token }; + var args = new TestArgs { UnityContainer = container, DataService = dataService, HttpClient = client, Token = token }; action(args); } } diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/BusinessServersTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/BusinessServersTest.cs index d654a0d4..6f1bfb16 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/BusinessServersTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/BusinessServersTest.cs @@ -19,10 +19,10 @@ public class BusinessServersTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public BusinessServersTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public BusinessServersTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/ChangeMasterInBSTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/ChangeMasterInBSTest.cs index 1b65fac9..a340a454 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/ChangeMasterInBSTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/ChangeMasterInBSTest.cs @@ -17,10 +17,10 @@ public class ChangeMasterInBSTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public ChangeMasterInBSTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public ChangeMasterInBSTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/CreateWithPseudoDetailDefinedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/CreateWithPseudoDetailDefinedTest.cs index e0ad87ae..f1aedc2b 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/CreateWithPseudoDetailDefinedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/CreateWithPseudoDetailDefinedTest.cs @@ -31,7 +31,7 @@ public CreateWithPseudoDetailDefinedTest() : base(pseudoDetailDefinitions: GetPs } #endif #if NETCOREAPP - public CreateWithPseudoDetailDefinedTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) : base(fixtureData, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) + public CreateWithPseudoDetailDefinedTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) : base(factory, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/GisCRUDTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/GisCRUDTest.cs index c10588b8..c3e7bbf0 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/GisCRUDTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/GisCRUDTest.cs @@ -35,10 +35,10 @@ public GisCRUDTest() /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод диагностической информации по тестам. - public GisCRUDTest(TestFixtureData fixtureData, ITestOutputHelper output) - : base(fixtureData, output, false, true) + public GisCRUDTest(CustomWebApplicationFactory factory, ITestOutputHelper output) + : base(factory, output, false, true) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/MultiThreadTests.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/MultiThreadTests.cs index 1656afd8..70c96ad1 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/MultiThreadTests.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/MultiThreadTests.cs @@ -54,10 +54,10 @@ public MultiThreadTests(Xunit.Abstractions.ITestOutputHelper output) /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public MultiThreadTests(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public MultiThreadTests(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/BuiltinQueryFunctionsTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/BuiltinQueryFunctionsTest.cs index cb1338ab..350dda1a 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/BuiltinQueryFunctionsTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/BuiltinQueryFunctionsTest.cs @@ -26,10 +26,10 @@ public class BuiltinQueryFunctionsTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public BuiltinQueryFunctionsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public BuiltinQueryFunctionsTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/Excel/ExcelExportTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/Excel/ExcelExportTest.cs index 33935650..9eabb8aa 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/Excel/ExcelExportTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/Excel/ExcelExportTest.cs @@ -19,10 +19,10 @@ public class ExcelExportTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public ExcelExportTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public ExcelExportTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterDetailFieldTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterDetailFieldTest.cs index 5e2e840b..eab57c08 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterDetailFieldTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterDetailFieldTest.cs @@ -22,10 +22,10 @@ public class FilterByMasterDetailFieldTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public FilterByMasterDetailFieldTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public FilterByMasterDetailFieldTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterFieldTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterFieldTest.cs index 74fcc413..283adb51 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterFieldTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterFieldTest.cs @@ -21,10 +21,10 @@ public class FilterByMasterFieldTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public FilterByMasterFieldTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public FilterByMasterFieldTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterMasterDetailFieldTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterMasterDetailFieldTest.cs index 96268e85..c7421e20 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterMasterDetailFieldTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByMasterMasterDetailFieldTest.cs @@ -22,10 +22,10 @@ public class FilterByMasterMasterDetailFieldTest : BaseODataServiceIntegratedTes /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public FilterByMasterMasterDetailFieldTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public FilterByMasterMasterDetailFieldTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs index e2608bfb..3ab57eb8 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs @@ -36,8 +36,8 @@ public FilterByPseudoDetailFieldTest() : base(pseudoDetailDefinitions: GetPseudo } #endif #if NETCOREAPP - public FilterByPseudoDetailFieldTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) + public FilterByPseudoDetailFieldTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) { _container.RegisterInstance(GetPseudoDetailDefinitions()); } diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterTest.cs index 3e00c170..8bff97a0 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterTest.cs @@ -25,10 +25,10 @@ public class FilterTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public FilterTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public FilterTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/GetTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/GetTest.cs index 916ba017..019014ad 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/GetTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/GetTest.cs @@ -25,10 +25,10 @@ public class GetTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public GetTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public GetTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/MetaDataTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/MetaDataTest.cs index 51449916..e90fbf41 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/MetaDataTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/MetaDataTest.cs @@ -21,10 +21,10 @@ public class MetaDataTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public MetaDataTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public MetaDataTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/ReferenceToMasterTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/ReferenceToMasterTest.cs index 021e2a22..ecbed583 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/ReferenceToMasterTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/ReferenceToMasterTest.cs @@ -24,10 +24,10 @@ public class ReferenceToMasterTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public ReferenceToMasterTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public ReferenceToMasterTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/SkipTopOrderByTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/SkipTopOrderByTest.cs index e2af17ce..fafca5aa 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/SkipTopOrderByTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/SkipTopOrderByTest.cs @@ -26,10 +26,10 @@ public class SkipTopOrderByTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public SkipTopOrderByTest(TestFixtureData fixtureData, ITestOutputHelper output) - : base(fixtureData, output) + public SkipTopOrderByTest(CustomWebApplicationFactory factory, ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/UtfRequestsTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/UtfRequestsTest.cs index a2a627c5..931f1a75 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/UtfRequestsTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/UtfRequestsTest.cs @@ -24,10 +24,10 @@ public class UtfRequestsTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public UtfRequestsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public UtfRequestsTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/BusinessServersTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/BusinessServersTest.cs index 2b3351b5..d4077833 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/BusinessServersTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/BusinessServersTest.cs @@ -25,10 +25,10 @@ public class BusinessServersTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public BusinessServersTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public BusinessServersTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/ModifyDataTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/ModifyDataTest.cs index d48ab800..ab44a57e 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/ModifyDataTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/ModifyDataTest.cs @@ -25,10 +25,10 @@ public class ModifyDataTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public ModifyDataTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public ModifyDataTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/WebFileTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/WebFileTest.cs index 3e5409f7..708d2bb5 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/WebFileTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Update/WebFileTest.cs @@ -19,10 +19,10 @@ public class WebFileTest: BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public WebFileTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public WebFileTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs index 926a4c23..759662d2 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs @@ -1,6 +1,7 @@ #if NETCOREAPP namespace NewPlatform.Flexberry.ORM.ODataService.Tests { + using System; using System.IO; using ICSSoft.Services; using Microsoft.AspNetCore.Hosting; @@ -14,13 +15,19 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests public class CustomWebApplicationFactory : WebApplicationFactory where TStartup : class { + public static Unity.IUnityContainer _unityContainer; + /// protected override IWebHostBuilder CreateWebHostBuilder() { + if (_unityContainer == null) + { + throw new Exception("Unity.IUnityContainer is not defined"); + } + string contentRootDirectory = Directory.GetCurrentDirectory(); - var container = UnityFactory.GetContainer(); var webHostBuilder = new WebHostBuilder() - .UseUnityServiceProvider(container) + .UseUnityServiceProvider(_unityContainer) .UseContentRoot(contentRootDirectory) .UseStartup(); return webHostBuilder; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs index 25bb79fc..4e108989 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs @@ -17,10 +17,10 @@ public class AfterGetTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public AfterGetTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public AfterGetTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterInternalServerErrorTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterInternalServerErrorTest.cs index a8caf46d..428eccb4 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterInternalServerErrorTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterInternalServerErrorTest.cs @@ -18,10 +18,10 @@ public class AfterInternalServerErrorTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public AfterInternalServerErrorTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public AfterInternalServerErrorTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterSaveTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterSaveTest.cs index bce04edc..52d93515 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterSaveTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterSaveTest.cs @@ -29,10 +29,10 @@ public class AfterSaveTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public AfterSaveTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public AfterSaveTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeGetTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeGetTest.cs index b9eb79d1..5644de97 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeGetTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeGetTest.cs @@ -22,10 +22,10 @@ public class BeforeGetTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public BeforeGetTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public BeforeGetTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeSaveTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeSaveTest.cs index 717a9332..153301b1 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeSaveTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeSaveTest.cs @@ -23,10 +23,10 @@ public class BeforeSaveTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public BeforeSaveTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public BeforeSaveTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Files/FileControllerTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Files/FileControllerTest.cs index 092a8cc1..9ba02a91 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Files/FileControllerTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Files/FileControllerTest.cs @@ -61,8 +61,8 @@ public class FileControllerTest : BaseODataServiceIntegratedTest #if NETFRAMEWORK public FileControllerTest() #elif NETCOREAPP - public FileControllerTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public FileControllerTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) #endif { _filesDirectoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files"); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/ActionsTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/ActionsTest.cs index ce2a261f..f5431b2a 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/ActionsTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/ActionsTest.cs @@ -35,10 +35,10 @@ public class ActionsTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public ActionsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public ActionsTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/DelegateFunctionsTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/DelegateFunctionsTest.cs index e12aa76a..f18e1521 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/DelegateFunctionsTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/DelegateFunctionsTest.cs @@ -19,10 +19,10 @@ public class DelegateFunctionsTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public DelegateFunctionsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public DelegateFunctionsTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/FunctionsTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/FunctionsTest.cs index 277503cd..5451e67f 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/FunctionsTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Functions/FunctionsTest.cs @@ -34,10 +34,10 @@ public class FunctionsTest : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. + /// Фабрика для приложения. /// Вывод отладочной информации. - public FunctionsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public FunctionsTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs index d21e6709..0b8b0703 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs @@ -21,9 +21,9 @@ public class CustomizationEdmModelNames : BaseODataServiceIntegratedTest /// /// Конструктор по-умолчанию. /// - /// Данные для теста. - public CustomizationEdmModelNames(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + /// Фабрика для приложения. + public CustomizationEdmModelNames(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs index 14ecd211..debbe59b 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs @@ -22,8 +22,8 @@ public class DefaultOfflineManagerIntegratedTest : BaseODataServiceIntegratedTes /// /// Конструктор по-умолчанию. /// - public DefaultOfflineManagerIntegratedTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) - : base(fixtureData, output) + public DefaultOfflineManagerIntegratedTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs index 292e3042..4c5954eb 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs @@ -30,8 +30,8 @@ public OfflineAuditServiceIntegratedTest() /// /// Initializes a new instance of the class. /// - public OfflineAuditServiceIntegratedTest(TestFixtureData fixtureData, ITestOutputHelper output) - : base(fixtureData, output, "offline") + public OfflineAuditServiceIntegratedTest(CustomWebApplicationFactory factory, ITestOutputHelper output) + : base(factory, output, "offline") { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs index a46607ce..adf79a7f 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs @@ -44,12 +44,29 @@ public Startup(IConfiguration configuration) public IConfiguration Configuration { get; } - public static IServiceProvider _serviceProvider; - - public static IUnityContainer _unityContainer; - public string CustomizationString => ""; + public virtual void ConfigureContainer(IUnityContainer unityContainer) + { + // Configure Flexberry services via Unity. + var securityManager = new EmptySecurityManager(); + Mock mockAuditService = new Mock(); + Mock mockBusinessServerProvider = new Mock(); + IDataService dataService = new PostgresDataService(securityManager, mockAuditService.Object, mockBusinessServerProvider.Object) { CustomizationString = CustomizationString }; + + unityContainer.RegisterType( + new InjectionConstructor( + unityContainer.IsRegistered() ? unityContainer.Resolve() : null, + unityContainer.IsRegistered("Export") ? unityContainer.Resolve("Export") : null, + unityContainer.IsRegistered() ? unityContainer.Resolve() : null, + unityContainer.IsRegistered("ExportStringedObjectView") ? unityContainer.Resolve("ExportStringedObjectView") : null, + unityContainer.IsRegistered() ? unityContainer.Resolve() : null, + unityContainer.IsRegistered("Export") ? unityContainer.Resolve("Export") : null)); + unityContainer.RegisterInstance(dataService); + unityContainer.RegisterInstance(new LockService(dataService)); + unityContainer.RegisterInstance(new EmptySecurityManager()); + } + // This method gets called by the runtime. Use this method to add services to the container. public virtual void ConfigureServices(IServiceCollection services) { @@ -68,29 +85,6 @@ public virtual void ConfigureServices(IServiceCollection services) } */ - // Configure Flexberry services via Unity. - IUnityContainer unityContainer = new UnityContainer(); - IServiceProvider serviceProvider = new UnityServiceProvider(unityContainer); - var securityManager = new EmptySecurityManager(); - Mock mockAuditService = new Mock(); - Mock mockBusinessServerProvider = new Mock(); - IDataService dataService = new PostgresDataService(securityManager, mockAuditService.Object, mockBusinessServerProvider.Object) { CustomizationString = CustomizationString }; - - unityContainer.RegisterType( - new InjectionConstructor( - unityContainer.IsRegistered() ? unityContainer.Resolve() : null, - unityContainer.IsRegistered("Export") ? unityContainer.Resolve("Export") : null, - unityContainer.IsRegistered() ? unityContainer.Resolve() : null, - unityContainer.IsRegistered("ExportStringedObjectView") ? unityContainer.Resolve("ExportStringedObjectView") : null, - unityContainer.IsRegistered() ? unityContainer.Resolve() : null, - unityContainer.IsRegistered("Export") ? unityContainer.Resolve("Export") : null)); - unityContainer.RegisterInstance(dataService); - unityContainer.RegisterInstance(new LockService(dataService)); - unityContainer.RegisterInstance(new EmptySecurityManager()); - - _unityContainer = unityContainer; - _serviceProvider = serviceProvider; - services.AddMvcCore(options => { options.Filters.Add(); @@ -140,7 +134,7 @@ public virtual void Configure(IApplicationBuilder app, IHostingEnvironment env) typeof(UserSetting).Assembly, typeof(Lock).Assembly, }; - var modelBuilder = new DefaultDataObjectEdmModelBuilder(assemblies, _serviceProvider, false); + var modelBuilder = new DefaultDataObjectEdmModelBuilder(assemblies, app.ApplicationServices, false); var token = builder.MapDataObjectRoute(modelBuilder); }); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestFixtureData.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestFixtureData.cs deleted file mode 100644 index 25d4b6ee..00000000 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestFixtureData.cs +++ /dev/null @@ -1,33 +0,0 @@ -#if NETCOREAPP -using ICSSoft.Services; -using ODataServiceSample.AspNetCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Unity; - -namespace NewPlatform.Flexberry.ORM.ODataService.Tests -{ - /// - /// Data class for all tests. - /// - public class TestFixtureData : IDisposable - { - public CustomWebApplicationFactory factory; - public IUnityContainer unityContainer; - - public TestFixtureData() - { - factory = new CustomWebApplicationFactory(); - unityContainer = UnityFactory.GetContainer(); - } - - public void Dispose() - { - factory.Dispose(); - } - } -} -#endif \ No newline at end of file diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs index e81b853e..ddedf417 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs @@ -12,7 +12,8 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using NewPlatform.Flexberry.ORM.ODataService.Model; using NewPlatform.Flexberry.ORM.ODataService.WebApi.Extensions; using NewPlatform.Flexberry.Services; - using ODataServiceSample.AspNetCore; + using ODataServiceSample.AspNetCore; + using System; using Unity; /// @@ -20,6 +21,8 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests /// public class TestStartup : Startup { + public static IUnityContainer _unityContainer; + /// /// Initialize new instance of TestStartup. /// @@ -29,11 +32,18 @@ public TestStartup(IConfiguration configuration) { } + public override void ConfigureContainer(IUnityContainer unityContainer) + { + _unityContainer = unityContainer; + base.ConfigureContainer(unityContainer); + } + /// public override void Configure(IApplicationBuilder app, IHostingEnvironment env) { - IUnityContainer unityContainer = new UnityContainer(); - unityContainer.RegisterInstance(env); + //IUnityContainer unityContainer = new UnityContainer(); + IServiceProvider serviceProvider = app.ApplicationServices; + _unityContainer.RegisterInstance(env); app.UseMiddleware(); @@ -53,8 +63,9 @@ public override void Configure(IApplicationBuilder app, IHostingEnvironment env) typeof(Lock).Assembly, }; - PseudoDetailDefinitions pseudoDetailDefinitions = (PseudoDetailDefinitions)_serviceProvider.GetService(typeof(PseudoDetailDefinitions)); - var modelBuilder = new DefaultDataObjectEdmModelBuilder(assemblies, _serviceProvider, false, pseudoDetailDefinitions); + + PseudoDetailDefinitions pseudoDetailDefinitions = (PseudoDetailDefinitions)serviceProvider.GetService(typeof(PseudoDetailDefinitions)); + var modelBuilder = new DefaultDataObjectEdmModelBuilder(assemblies, serviceProvider, false, pseudoDetailDefinitions); var token = builder.MapDataObjectRoute(modelBuilder); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs index 6e9754ca..a01b1c72 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs @@ -8,6 +8,8 @@ namespace NewPlatform.Flexberry.ORM.IntegratedTests using System.IO; using System.Reflection; using System.Text; + + using ODataServiceSample.AspNetCore; #endif using ICSSoft.Services; @@ -18,10 +20,12 @@ namespace NewPlatform.Flexberry.ORM.IntegratedTests using ICSSoft.STORMNET.Windows.Forms; using Moq; using NewPlatform.Flexberry.ORM.ODataService.Tests; + using Unity; using Xunit.Abstractions; - using Xunit.Sdk; - + using Xunit.Sdk; + using Microsoft.Practices.Unity.Configuration; + /// /// Инициализация тестового запуска. /// @@ -33,23 +37,23 @@ public class XUnitTestRunnerInitializer : XunitTestFramework /// The message sink used to send diagnostic messages. public XUnitTestRunnerInitializer(IMessageSink messageSink) : base(messageSink) - { - var container = new UnityContainer(); - IServiceProvider serviceProvider = new UnityServiceProvider(container); - IBusinessServerProvider businessServerProvider = new BusinessServerProvider(serviceProvider); - IDataService ds = new MSSQLDataService(new Mock().Object, new Mock().Object, businessServerProvider); - BaseIntegratedTest.BSProvider = businessServerProvider; + { + IBusinessServerProvider businessServerProvider = new Mock().Object; + IDataService ds = new MSSQLDataService(new Mock().Object, new Mock().Object, new Mock().Object); + DataServiceProvider.DataService = ds; ExternalLangDef.LanguageDef = new ExternalLangDef(ds); DetailVariableDef.ViewGenerator = null; - + #if NETCOREAPP Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); string configFile = $"{Assembly.GetExecutingAssembly().Location}.config"; string outputConfigFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath; File.Copy(configFile, outputConfigFile, true); #endif + + BaseIntegratedTest.BSProvider = businessServerProvider; } } } From 98c211210af1697872fdef4c880a9925a9adc4d3 Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Fri, 2 Jun 2023 11:24:10 +0500 Subject: [PATCH 20/40] Added proper business server provider initialisation --- .../BaseIntegratedTest.cs | 22 +++++-------------- .../Startup.cs | 3 ++- .../XUnitTestRunnerInitializer.cs | 2 -- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index faead98b..c65d0430 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -43,22 +43,6 @@ public abstract class BaseIntegratedTest : IClassFixture - /// Provider for injection to data services for test purposes. - ///
- public static IBusinessServerProvider BSProvider - { - set - { - if (businessServerProvider != null) - { - throw new Exception("BusinessServerProvider should not be initialized twice."); - } - - businessServerProvider = value; - } - } - /// /// Provider for injection to data services for test purposes. /// @@ -160,8 +144,11 @@ public void Dispose() /// Use DataService with Gis support. protected BaseIntegratedTest(string tempDbNamePrefix, bool useGisDataService = false) { + // TODO: сделать код не повторяющимся. _container = new UnityContainer(); _serviceProvider = new UnityServiceProvider(_container); + _container.RegisterFactory(new Func(o => new BusinessServerProvider(new UnityServiceProvider(o))), FactoryLifetime.Singleton); + businessServerProvider = _container.Resolve(); #endif #if NETCOREAPP /// @@ -177,6 +164,9 @@ protected BaseIntegratedTest(CustomWebApplicationFactory factory, ITest _container = new UnityContainer(); _container.LoadConfiguration(); _serviceProvider = new UnityServiceProvider(_container); + _container.RegisterFactory(new Func(o => new BusinessServerProvider(new UnityServiceProvider(o))), FactoryLifetime.Singleton); + businessServerProvider = _container.Resolve(); + CustomWebApplicationFactory._unityContainer = _container; _output = output; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs index adf79a7f..b9c72455 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs @@ -52,7 +52,8 @@ public virtual void ConfigureContainer(IUnityContainer unityContainer) var securityManager = new EmptySecurityManager(); Mock mockAuditService = new Mock(); Mock mockBusinessServerProvider = new Mock(); - IDataService dataService = new PostgresDataService(securityManager, mockAuditService.Object, mockBusinessServerProvider.Object) { CustomizationString = CustomizationString }; + IBusinessServerProvider businessServerProvider = unityContainer.Resolve(); + IDataService dataService = new PostgresDataService(securityManager, mockAuditService.Object, businessServerProvider) { CustomizationString = CustomizationString }; unityContainer.RegisterType( new InjectionConstructor( diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs index a01b1c72..f7e57da6 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs @@ -52,8 +52,6 @@ public XUnitTestRunnerInitializer(IMessageSink messageSink) string outputConfigFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath; File.Copy(configFile, outputConfigFile, true); #endif - - BaseIntegratedTest.BSProvider = businessServerProvider; } } } From 4d087c2e9ed6b5b0908c9969d9d1f286de38ceaa Mon Sep 17 00:00:00 2001 From: Andrey Chibisov Date: Fri, 2 Jun 2023 14:57:57 +0500 Subject: [PATCH 21/40] Code cleanup --- .../App.config | 2 +- .../BaseIntegratedTest.cs | 22 +++++++++---------- .../BaseODataServiceIntegratedTest.cs | 18 +++++++-------- .../CreateWithPseudoDetailDefinedTest.cs | 8 ++++++- .../Read/FilterByPseudoDetailFieldTest.cs | 5 +++++ .../CustomWebApplicationFactory.cs | 1 - .../Files/FileControllerTest.cs | 7 +++++- .../Model/CustomizationEdmModelNames.cs | 5 +++-- .../DefaultOfflineManagerIntegratedTest.cs | 19 +++++++--------- .../OfflineAuditServiceIntegratedTest.cs | 6 +++-- .../Startup.cs | 6 +---- .../TestStartup.cs | 8 +++---- .../XUnitTestRunnerInitializer.cs | 13 ++--------- 13 files changed, 59 insertions(+), 61 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config index aa7b5699..096fd39d 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config @@ -6,7 +6,7 @@ - + diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index c65d0430..4b19070a 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -8,6 +8,7 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using System.Data.SqlClient; using System.Linq; using System.Threading; + using ICSSoft.Services; using ICSSoft.STORMNET.Business; using ICSSoft.STORMNET.Business.Audit; using ICSSoft.STORMNET.Business.Interfaces; @@ -15,10 +16,9 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using Moq; using Npgsql; using Oracle.ManagedDataAccess.Client; + using Unity; using Xunit; using Xunit.Abstractions; - using Unity; - using ICSSoft.Services; #if NETFRAMEWORK /// @@ -29,8 +29,8 @@ public abstract class BaseIntegratedTest : IDisposable #endif #if NETCOREAPP using Microsoft.AspNetCore.Mvc.Testing; - using ODataServiceSample.AspNetCore; using Microsoft.Practices.Unity.Configuration; + using ODataServiceSample.AspNetCore; /// /// Base class for integration tests. @@ -134,8 +134,8 @@ static BaseIntegratedTest() public void Dispose() { Dispose(true); - } - + } + #if NETFRAMEWORK /// /// Initializes a new instance of the class. @@ -144,12 +144,8 @@ public void Dispose() /// Use DataService with Gis support. protected BaseIntegratedTest(string tempDbNamePrefix, bool useGisDataService = false) { - // TODO: сделать код не повторяющимся. - _container = new UnityContainer(); - _serviceProvider = new UnityServiceProvider(_container); - _container.RegisterFactory(new Func(o => new BusinessServerProvider(new UnityServiceProvider(o))), FactoryLifetime.Singleton); - businessServerProvider = _container.Resolve(); #endif + #if NETCOREAPP /// /// Initializes a new instance of the class. @@ -161,12 +157,16 @@ protected BaseIntegratedTest(string tempDbNamePrefix, bool useGisDataService = f protected BaseIntegratedTest(CustomWebApplicationFactory factory, ITestOutputHelper output, string tempDbNamePrefix, bool useGisDataService = false) { _factory = factory; +#endif + _container = new UnityContainer(); +#if NETCOREAPP _container.LoadConfiguration(); +#endif _serviceProvider = new UnityServiceProvider(_container); _container.RegisterFactory(new Func(o => new BusinessServerProvider(new UnityServiceProvider(o))), FactoryLifetime.Singleton); businessServerProvider = _container.Resolve(); - +#if NETCOREAPP CustomWebApplicationFactory._unityContainer = _container; _output = output; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index 7e4be422..a6df1d07 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -3,14 +3,9 @@ using System; using System.Net; using System.Net.Http; - using System.Net.Http.Headers; using System.Reflection; - using System.Text; - using ICSSoft.Services; using ICSSoft.STORMNET; using ICSSoft.STORMNET.Business; - using ICSSoft.STORMNET.KeyGen; - using ICSSoft.STORMNET.Windows.Forms; using NewPlatform.Flexberry.ORM.ODataService.Files; using NewPlatform.Flexberry.ORM.ODataService.Model; using NewPlatform.Flexberry.ORM.ODataService.Tests.Helpers; @@ -22,14 +17,12 @@ #if NETFRAMEWORK using System.Web.Http; using System.Web.Http.Cors; - using Microsoft.AspNet.OData.Batch; using NewPlatform.Flexberry.ORM.ODataService.Extensions; using NewPlatform.Flexberry.ORM.ODataService.WebApi.Extensions; using Unity.AspNet.WebApi; #endif #if NETCOREAPP using NewPlatform.Flexberry.ORM.ODataService.Routing; - using ODataServiceSample.AspNetCore; #endif /// @@ -72,6 +65,14 @@ public BaseODataServiceIntegratedTest( } #endif #if NETCOREAPP + /// + /// Initializes a new instance of the class. + /// + /// Factory for application. + /// Debug information output. + /// Flag indicating whether type namespaces should be added to the names of their corresponding entity sets. + /// Flag indicating whether GisDataService be used. + /// OData definition of the link from master to pseudodetail (pseudoproperty). public BaseODataServiceIntegratedTest(CustomWebApplicationFactory factory, ITestOutputHelper output = null, bool useNamespaceInEntitySetName = false, bool useGisDataService = false, PseudoDetailDefinitions pseudoDetailDefinitions = null) : base(factory, output, "ODataDB", useGisDataService) { @@ -89,8 +90,6 @@ private void Init( }; UseNamespaceInEntitySetName = useNamespaceInEntitySetName; - - _container.RegisterInstance(null); _builder = new DefaultDataObjectEdmModelBuilder(DataObjectsAssembliesNames, _serviceProvider, UseNamespaceInEntitySetName, pseudoDetailDefinitions); } @@ -127,7 +126,6 @@ public virtual void ActODataService(Action action) foreach (IDataService dataService in DataServices) { - //using (var container = new UnityContainer()) using (var config = new HttpConfiguration()) using (var server = new HttpServer(config)) using (var client = new HttpClient(server, false) { BaseAddress = new Uri("http://localhost/odata/") }) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/CreateWithPseudoDetailDefinedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/CreateWithPseudoDetailDefinedTest.cs index f1aedc2b..0babf64c 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/CreateWithPseudoDetailDefinedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Create/CreateWithPseudoDetailDefinedTest.cs @@ -31,7 +31,13 @@ public CreateWithPseudoDetailDefinedTest() : base(pseudoDetailDefinitions: GetPs } #endif #if NETCOREAPP - public CreateWithPseudoDetailDefinedTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) : base(factory, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) + /// + /// Initializes a new instance of the class. + /// + /// Factory for application. + /// Debug information output. + public CreateWithPseudoDetailDefinedTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) + : base(factory, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs index 3ab57eb8..f1dd44e1 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs @@ -36,6 +36,11 @@ public FilterByPseudoDetailFieldTest() : base(pseudoDetailDefinitions: GetPseudo } #endif #if NETCOREAPP + /// + /// Initializes a new instance of the class. + /// + /// Factory for application. + /// Debug information output. public FilterByPseudoDetailFieldTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) : base(factory, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) { diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs index 759662d2..178bf117 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs @@ -3,7 +3,6 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests { using System; using System.IO; - using ICSSoft.Services; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Unity.Microsoft.DependencyInjection; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Files/FileControllerTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Files/FileControllerTest.cs index 9ba02a91..a41cfce3 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Files/FileControllerTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Files/FileControllerTest.cs @@ -55,12 +55,17 @@ public class FileControllerTest : BaseODataServiceIntegratedTest /// private static string _srcTextFilePath; +#if NETFRAMEWORK /// /// Инициализирует тестовый класс (инициализация выполняется перед запуском тестов). /// -#if NETFRAMEWORK public FileControllerTest() #elif NETCOREAPP + /// + /// Initializes a new instance of the class. + /// + /// Factory for application. + /// Debug information output. public FileControllerTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) : base(factory, output) #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs index 0b8b0703..656c56e8 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs @@ -19,9 +19,10 @@ public class CustomizationEdmModelNames : BaseODataServiceIntegratedTest { #if NETCOREAPP /// - /// Конструктор по-умолчанию. + /// Initializes a new instance of the class. /// - /// Фабрика для приложения. + /// Factory for application. + /// Debug information output. public CustomizationEdmModelNames(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) : base(factory, output) { diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs index debbe59b..a12e4345 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/DefaultOfflineManagerIntegratedTest.cs @@ -2,26 +2,23 @@ { using System; using System.Collections.Generic; - - using ICSSoft.Services; using ICSSoft.STORMNET; - - using Unity; - using Xunit; - using Moq; - + using NewPlatform.Flexberry.ORM.CurrentUserService; using NewPlatform.Flexberry.ORM.ODataService.Offline; using NewPlatform.Flexberry.ORM.ODataService.Tests.Extensions; using NewPlatform.Flexberry.Services; - using NewPlatform.Flexberry.ORM.CurrentUserService; + using Unity; + using Xunit; public class DefaultOfflineManagerIntegratedTest : BaseODataServiceIntegratedTest - { + { #if NETCOREAPP /// - /// Конструктор по-умолчанию. - /// + /// Initializes a new instance of the class. + /// + /// Factory for application. + /// Debug information output. public DefaultOfflineManagerIntegratedTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) : base(factory, output) { } diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs index 4c5954eb..2796d429 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Offline/OfflineAuditServiceIntegratedTest.cs @@ -16,7 +16,7 @@ /// /// public class OfflineAuditServiceIntegratedTest : BaseIntegratedTest - { + { #if NETFRAMEWORK /// /// Initializes a new instance of the class. @@ -29,7 +29,9 @@ public OfflineAuditServiceIntegratedTest() #if NETCOREAPP /// /// Initializes a new instance of the class. - /// + /// + /// Factory for application. + /// Debug information output. public OfflineAuditServiceIntegratedTest(CustomWebApplicationFactory factory, ITestOutputHelper output) : base(factory, output, "offline") { diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs index b9c72455..931c71b0 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs @@ -2,16 +2,13 @@ namespace ODataServiceSample.AspNetCore { using System; - using System.IO; using System.Linq; using ICSSoft.Services; using ICSSoft.STORMNET.Business; using ICSSoft.STORMNET.Business.Audit; using ICSSoft.STORMNET.Business.Interfaces; using ICSSoft.STORMNET.Security; - using ICSSoft.STORMNET.Windows.Forms; using IIS.Caseberry.Logging.Objects; - using Microsoft.AspNet.OData.Extensions; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; @@ -51,7 +48,6 @@ public virtual void ConfigureContainer(IUnityContainer unityContainer) // Configure Flexberry services via Unity. var securityManager = new EmptySecurityManager(); Mock mockAuditService = new Mock(); - Mock mockBusinessServerProvider = new Mock(); IBusinessServerProvider businessServerProvider = unityContainer.Resolve(); IDataService dataService = new PostgresDataService(securityManager, mockAuditService.Object, businessServerProvider) { CustomizationString = CustomizationString }; @@ -81,7 +77,7 @@ public virtual void ConfigureServices(IServiceCollection services) return dataService; }); - + services.AddSingleton(); } */ diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs index ddedf417..3c347503 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs @@ -1,6 +1,7 @@ #if NETCOREAPP namespace NewPlatform.Flexberry.ORM.ODataService.Tests { + using System; using ICSSoft.Services; using IIS.Caseberry.Logging.Objects; using Microsoft.AspNetCore.Builder; @@ -13,7 +14,6 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using NewPlatform.Flexberry.ORM.ODataService.WebApi.Extensions; using NewPlatform.Flexberry.Services; using ODataServiceSample.AspNetCore; - using System; using Unity; /// @@ -41,7 +41,6 @@ public override void ConfigureContainer(IUnityContainer unityContainer) /// public override void Configure(IApplicationBuilder app, IHostingEnvironment env) { - //IUnityContainer unityContainer = new UnityContainer(); IServiceProvider serviceProvider = app.ApplicationServices; _unityContainer.RegisterInstance(env); @@ -61,9 +60,8 @@ public override void Configure(IApplicationBuilder app, IHostingEnvironment env) typeof(ApplicationLog).Assembly, typeof(UserSetting).Assembly, typeof(Lock).Assembly, - }; - - + }; + PseudoDetailDefinitions pseudoDetailDefinitions = (PseudoDetailDefinitions)serviceProvider.GetService(typeof(PseudoDetailDefinitions)); var modelBuilder = new DefaultDataObjectEdmModelBuilder(assemblies, serviceProvider, false, pseudoDetailDefinitions); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs index f7e57da6..5dcb3482 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs @@ -2,29 +2,21 @@ namespace NewPlatform.Flexberry.ORM.IntegratedTests { - using System; #if NETCOREAPP using System.Configuration; using System.IO; using System.Reflection; using System.Text; - - using ODataServiceSample.AspNetCore; #endif - using ICSSoft.Services; using ICSSoft.STORMNET.Business; using ICSSoft.STORMNET.Business.Audit; using ICSSoft.STORMNET.Business.Interfaces; using ICSSoft.STORMNET.Security; - using ICSSoft.STORMNET.Windows.Forms; + using ICSSoft.STORMNET.Windows.Forms; using Moq; - using NewPlatform.Flexberry.ORM.ODataService.Tests; - - using Unity; using Xunit.Abstractions; using Xunit.Sdk; - using Microsoft.Practices.Unity.Configuration; /// /// Инициализация тестового запуска. @@ -40,8 +32,7 @@ public XUnitTestRunnerInitializer(IMessageSink messageSink) { IBusinessServerProvider businessServerProvider = new Mock().Object; IDataService ds = new MSSQLDataService(new Mock().Object, new Mock().Object, new Mock().Object); - - + DataServiceProvider.DataService = ds; ExternalLangDef.LanguageDef = new ExternalLangDef(ds); DetailVariableDef.ViewGenerator = null; From d23e1b56229938f728f3a8ed3b9387dfd8268283 Mon Sep 17 00:00:00 2001 From: Andrey Chibisov Date: Fri, 2 Jun 2023 15:43:33 +0500 Subject: [PATCH 22/40] App.config rollback --- .../App.config | 302 +++++++++--------- 1 file changed, 151 insertions(+), 151 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config index 096fd39d..a231cd7f 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/App.config @@ -1,163 +1,163 @@  - -
-
- - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c6aa544a4b6974506d11a9f4a6cf1b119912add2 Mon Sep 17 00:00:00 2001 From: Andrey Chibisov Date: Fri, 2 Jun 2023 17:38:27 +0500 Subject: [PATCH 23/40] Fix after code review --- .../BaseIntegratedTest.cs | 6 +++--- .../CustomWebApplicationFactory.cs | 8 +++++++- .../Startup.cs | 8 ++++++-- .../TestStartup.cs | 8 ++++++-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index 4b19070a..f8d3fa43 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -39,9 +39,9 @@ public abstract class BaseIntegratedTest : IClassFixture _factory; #endif - public static IUnityContainer _container; + protected IUnityContainer _container; - public static IServiceProvider _serviceProvider; + protected IServiceProvider _serviceProvider; /// /// Provider for injection to data services for test purposes. @@ -162,7 +162,7 @@ protected BaseIntegratedTest(CustomWebApplicationFactory factory, ITest _container = new UnityContainer(); #if NETCOREAPP _container.LoadConfiguration(); -#endif +#endif _serviceProvider = new UnityServiceProvider(_container); _container.RegisterFactory(new Func(o => new BusinessServerProvider(new UnityServiceProvider(o))), FactoryLifetime.Singleton); businessServerProvider = _container.Resolve(); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs index 178bf117..b80e7c7b 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs @@ -13,7 +13,13 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests /// Startup type. public class CustomWebApplicationFactory : WebApplicationFactory where TStartup : class - { + { + /// + /// Unity container is created in only one place: . + /// Further, it autimatically appears in a child , where ODataService starts. + /// The service is started in this class. Therefore, the Unity container must be passed to the running application here, + /// being initialized earlier. + /// public static Unity.IUnityContainer _unityContainer; /// diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs index 931c71b0..f3a62011 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs @@ -41,8 +41,12 @@ public Startup(IConfiguration configuration) public IConfiguration Configuration { get; } - public string CustomizationString => ""; - + public string CustomizationString => ""; + + /// + /// Method for Unity container configuring. + /// + /// Unity container. public virtual void ConfigureContainer(IUnityContainer unityContainer) { // Configure Flexberry services via Unity. diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs index 3c347503..1a98ff30 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs @@ -30,8 +30,12 @@ public class TestStartup : Startup public TestStartup(IConfiguration configuration) : base(configuration) { - } - + } + + /// + /// Method for Unity container configuring. + /// + /// Unity container. public override void ConfigureContainer(IUnityContainer unityContainer) { _unityContainer = unityContainer; From 5c250f1a9142cbaeb19cb44af124ded39dddc653 Mon Sep 17 00:00:00 2001 From: Andrey Chibisov Date: Mon, 5 Jun 2023 10:06:29 +0500 Subject: [PATCH 24/40] Comment for static field --- .../TestStartup.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs index 1a98ff30..9978e1cd 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs @@ -20,7 +20,12 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests /// Startup for tests. /// public class TestStartup : Startup - { + { + /// + /// After the start of the OData app, the container in the OData app is its own. + /// Therefore, a static field is defined here, so that later this container can be pulled back. + /// + /// public static IUnityContainer _unityContainer; /// From f01edf8cd1f688043233ffb6319e2aca2603427f Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 15:02:17 +0500 Subject: [PATCH 25/40] Added NuGet.config --- NewPlatform.Flexberry.ORM.ODataService.sln | 179 +++++++++++---------- NuGet.config | 7 + 2 files changed, 97 insertions(+), 89 deletions(-) create mode 100644 NuGet.config diff --git a/NewPlatform.Flexberry.ORM.ODataService.sln b/NewPlatform.Flexberry.ORM.ODataService.sln index 040b93c8..596894be 100644 --- a/NewPlatform.Flexberry.ORM.ODataService.sln +++ b/NewPlatform.Flexberry.ORM.ODataService.sln @@ -1,89 +1,90 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32602.215 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService", "NewPlatform.Flexberry.ORM.ODataService\NewPlatform.Flexberry.ORM.ODataService.csproj", "{01BBE45A-3A3F-4EA5-9457-8C62167B5E99}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet Package Properties", "NuGet Package Properties", "{EF5F8D62-3B41-44F8-B748-E5CE1CBF00A9}" - ProjectSection(SolutionItems) = preProject - NewPlatform.Flexberry.ORM.ODataService.nuspec = NewPlatform.Flexberry.ORM.ODataService.nuspec - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{A94D831A-7B5D-40C6-B76B-2B8B6335DB3E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.Tests", "Tests\NewPlatform.Flexberry.ORM.ODataService.Tests\NewPlatform.Flexberry.ORM.ODataService.Tests.csproj", "{8E43819E-6643-4E5F-A3A2-B1C212033DE6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.Tests.Objects", "Tests\Objects\NewPlatform.Flexberry.ORM.ODataService.Tests.Objects.csproj", "{10CE2502-3EEF-4285-935F-E18F5F623C6D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.Tests.BusinessServers", "Tests\BusinessServers\NewPlatform.Flexberry.ORM.ODataService.Tests.BusinessServers.csproj", "{BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Open Source", "Open Source", "{DB00E5CF-65B6-4A94-8C83-A80DB75E9B02}" - ProjectSection(SolutionItems) = preProject - .gitignore = .gitignore - .github\workflows\build.yml = .github\workflows\build.yml - CHANGELOG.md = CHANGELOG.md - ConfigTuner.ps1 = ConfigTuner.ps1 - LICENSE.md = LICENSE.md - README.md = README.md - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.Files", "NewPlatform.Flexberry.ORM.ODataService.Files\NewPlatform.Flexberry.ORM.ODataService.Files.csproj", "{22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.WebApi", "NewPlatform.Flexberry.ORM.ODataService.WebApi\NewPlatform.Flexberry.ORM.ODataService.WebApi.csproj", "{D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataServiceCore.Common", "NewPlatform.Flexberry.ORM.ODataServiceCore.Common\NewPlatform.Flexberry.ORM.ODataServiceCore.Common.csproj", "{2C84BB80-78BD-4771-BA5A-32D32DB568DE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataServiceCore.WebApi", "NewPlatform.Flexberry.ORM.ODataServiceCore.WebApi\NewPlatform.Flexberry.ORM.ODataServiceCore.WebApi.csproj", "{B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {01BBE45A-3A3F-4EA5-9457-8C62167B5E99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {01BBE45A-3A3F-4EA5-9457-8C62167B5E99}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01BBE45A-3A3F-4EA5-9457-8C62167B5E99}.Release|Any CPU.ActiveCfg = Release|Any CPU - {01BBE45A-3A3F-4EA5-9457-8C62167B5E99}.Release|Any CPU.Build.0 = Release|Any CPU - {8E43819E-6643-4E5F-A3A2-B1C212033DE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8E43819E-6643-4E5F-A3A2-B1C212033DE6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8E43819E-6643-4E5F-A3A2-B1C212033DE6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8E43819E-6643-4E5F-A3A2-B1C212033DE6}.Release|Any CPU.Build.0 = Release|Any CPU - {10CE2502-3EEF-4285-935F-E18F5F623C6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10CE2502-3EEF-4285-935F-E18F5F623C6D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10CE2502-3EEF-4285-935F-E18F5F623C6D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10CE2502-3EEF-4285-935F-E18F5F623C6D}.Release|Any CPU.Build.0 = Release|Any CPU - {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}.Release|Any CPU.Build.0 = Release|Any CPU - {22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}.Release|Any CPU.Build.0 = Release|Any CPU - {D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}.Release|Any CPU.Build.0 = Release|Any CPU - {2C84BB80-78BD-4771-BA5A-32D32DB568DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2C84BB80-78BD-4771-BA5A-32D32DB568DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2C84BB80-78BD-4771-BA5A-32D32DB568DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2C84BB80-78BD-4771-BA5A-32D32DB568DE}.Release|Any CPU.Build.0 = Release|Any CPU - {B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {8E43819E-6643-4E5F-A3A2-B1C212033DE6} = {A94D831A-7B5D-40C6-B76B-2B8B6335DB3E} - {10CE2502-3EEF-4285-935F-E18F5F623C6D} = {A94D831A-7B5D-40C6-B76B-2B8B6335DB3E} - {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9} = {A94D831A-7B5D-40C6-B76B-2B8B6335DB3E} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {611B715C-AD46-45B1-BA4E-36C8F1A1896E} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32602.215 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService", "NewPlatform.Flexberry.ORM.ODataService\NewPlatform.Flexberry.ORM.ODataService.csproj", "{01BBE45A-3A3F-4EA5-9457-8C62167B5E99}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet Package Properties", "NuGet Package Properties", "{EF5F8D62-3B41-44F8-B748-E5CE1CBF00A9}" + ProjectSection(SolutionItems) = preProject + NewPlatform.Flexberry.ORM.ODataService.nuspec = NewPlatform.Flexberry.ORM.ODataService.nuspec + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{A94D831A-7B5D-40C6-B76B-2B8B6335DB3E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.Tests", "Tests\NewPlatform.Flexberry.ORM.ODataService.Tests\NewPlatform.Flexberry.ORM.ODataService.Tests.csproj", "{8E43819E-6643-4E5F-A3A2-B1C212033DE6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.Tests.Objects", "Tests\Objects\NewPlatform.Flexberry.ORM.ODataService.Tests.Objects.csproj", "{10CE2502-3EEF-4285-935F-E18F5F623C6D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.Tests.BusinessServers", "Tests\BusinessServers\NewPlatform.Flexberry.ORM.ODataService.Tests.BusinessServers.csproj", "{BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Open Source", "Open Source", "{DB00E5CF-65B6-4A94-8C83-A80DB75E9B02}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + .github\workflows\build.yml = .github\workflows\build.yml + CHANGELOG.md = CHANGELOG.md + ConfigTuner.ps1 = ConfigTuner.ps1 + LICENSE.md = LICENSE.md + NuGet.config = NuGet.config + README.md = README.md + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.Files", "NewPlatform.Flexberry.ORM.ODataService.Files\NewPlatform.Flexberry.ORM.ODataService.Files.csproj", "{22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataService.WebApi", "NewPlatform.Flexberry.ORM.ODataService.WebApi\NewPlatform.Flexberry.ORM.ODataService.WebApi.csproj", "{D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataServiceCore.Common", "NewPlatform.Flexberry.ORM.ODataServiceCore.Common\NewPlatform.Flexberry.ORM.ODataServiceCore.Common.csproj", "{2C84BB80-78BD-4771-BA5A-32D32DB568DE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewPlatform.Flexberry.ORM.ODataServiceCore.WebApi", "NewPlatform.Flexberry.ORM.ODataServiceCore.WebApi\NewPlatform.Flexberry.ORM.ODataServiceCore.WebApi.csproj", "{B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {01BBE45A-3A3F-4EA5-9457-8C62167B5E99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01BBE45A-3A3F-4EA5-9457-8C62167B5E99}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01BBE45A-3A3F-4EA5-9457-8C62167B5E99}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01BBE45A-3A3F-4EA5-9457-8C62167B5E99}.Release|Any CPU.Build.0 = Release|Any CPU + {8E43819E-6643-4E5F-A3A2-B1C212033DE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E43819E-6643-4E5F-A3A2-B1C212033DE6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E43819E-6643-4E5F-A3A2-B1C212033DE6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E43819E-6643-4E5F-A3A2-B1C212033DE6}.Release|Any CPU.Build.0 = Release|Any CPU + {10CE2502-3EEF-4285-935F-E18F5F623C6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10CE2502-3EEF-4285-935F-E18F5F623C6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10CE2502-3EEF-4285-935F-E18F5F623C6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10CE2502-3EEF-4285-935F-E18F5F623C6D}.Release|Any CPU.Build.0 = Release|Any CPU + {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9}.Release|Any CPU.Build.0 = Release|Any CPU + {22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22FAA967-EA69-4AE9-9A07-ECEE6C499BBB}.Release|Any CPU.Build.0 = Release|Any CPU + {D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3EBD348-D0F8-4C1E-BDC0-6C77D9D443CB}.Release|Any CPU.Build.0 = Release|Any CPU + {2C84BB80-78BD-4771-BA5A-32D32DB568DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C84BB80-78BD-4771-BA5A-32D32DB568DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C84BB80-78BD-4771-BA5A-32D32DB568DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C84BB80-78BD-4771-BA5A-32D32DB568DE}.Release|Any CPU.Build.0 = Release|Any CPU + {B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9E13B47-4A51-4D47-B5B1-2C1A3A8008B1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {8E43819E-6643-4E5F-A3A2-B1C212033DE6} = {A94D831A-7B5D-40C6-B76B-2B8B6335DB3E} + {10CE2502-3EEF-4285-935F-E18F5F623C6D} = {A94D831A-7B5D-40C6-B76B-2B8B6335DB3E} + {BFB771C3-51D8-4804-BB0F-A0B4BD7981D9} = {A94D831A-7B5D-40C6-B76B-2B8B6335DB3E} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {611B715C-AD46-45B1-BA4E-36C8F1A1896E} + EndGlobalSection +EndGlobal diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 00000000..a157bfd8 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file From d7f7063595272d4f01f4effc5057f42a7e1a2a4e Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 21:33:08 +0500 Subject: [PATCH 26/40] Try to fix server tests --- .../Extensions/HttpConfigurationExtensions.cs | 1 - .../BaseODataServiceIntegratedTest.cs | 14 +++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NewPlatform.Flexberry.ORM.ODataService/Extensions/HttpConfigurationExtensions.cs b/NewPlatform.Flexberry.ORM.ODataService/Extensions/HttpConfigurationExtensions.cs index 3d412f8f..ea2af4a4 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Extensions/HttpConfigurationExtensions.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Extensions/HttpConfigurationExtensions.cs @@ -83,7 +83,6 @@ public static ManagementToken MapDataObjectRoute( // Model. DataObjectEdmModel model = builder.Build(); - config.DependencyResolver.GetService(typeof(DataObjectEdmModel)); // DataService for batch requests support. IDataService dataService = (IDataService)config.DependencyResolver.GetService(typeof(IDataService)); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index a6df1d07..a7f6cd98 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -19,12 +19,13 @@ using System.Web.Http.Cors; using NewPlatform.Flexberry.ORM.ODataService.Extensions; using NewPlatform.Flexberry.ORM.ODataService.WebApi.Extensions; - using Unity.AspNet.WebApi; + using Unity.AspNet.WebApi; + using Unity.Injection; #endif #if NETCOREAPP using NewPlatform.Flexberry.ORM.ODataService.Routing; #endif - + /// /// Базовый класс для тестирования работы с данными через ODataService. /// @@ -90,7 +91,14 @@ private void Init( }; UseNamespaceInEntitySetName = useNamespaceInEntitySetName; - _container.RegisterInstance(null); + _container.RegisterInstance( + new DataObjectEdmModelDependencies(_container.IsRegistered() ? _container.Resolve() : null, + _container.IsRegistered("Export") ? _container.Resolve("Export") : null, + _container.IsRegistered() ? _container.Resolve() : null, + _container.IsRegistered("ExportStringedObjectView") ? _container.Resolve("ExportStringedObjectView") : null, + _container.IsRegistered() ? _container.Resolve() : null, + _container.IsRegistered("Export") ? _container.Resolve("Export") : null)); + _builder = new DefaultDataObjectEdmModelBuilder(DataObjectsAssembliesNames, _serviceProvider, UseNamespaceInEntitySetName, pseudoDetailDefinitions); } From 4b70a042fbcaae06bd0f673e146ced2796f9e0fb Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 21:49:27 +0500 Subject: [PATCH 27/40] Try to fix github build --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5dc2f78..a367ab65 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,7 +73,7 @@ jobs: dotnet-version: 7.0.x - name: Restore NewPlatform.Flexberry.ORM.ODataService.sln - run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln + run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln -s https://api.nuget.org/v3/index.json - name: Install xunit.runner.console run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner From 16ca4718b89ee8105a683e3293d55d4761df18fe Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 21:56:17 +0500 Subject: [PATCH 28/40] Try to fix github build --- .github/workflows/build.yml | 4 ++-- .../BaseODataServiceIntegratedTest.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a367ab65..76d2de8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,10 +73,10 @@ jobs: dotnet-version: 7.0.x - name: Restore NewPlatform.Flexberry.ORM.ODataService.sln - run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln -s https://api.nuget.org/v3/index.json + run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln - name: Install xunit.runner.console - run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner + run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner -Source https://api.nuget.org/v3/index.json - name: Compile code run: dotnet build --no-restore -v q /p:WarningLevel=0 -c $CONFIGURATION NewPlatform.Flexberry.ORM.ODataService.sln diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index a7f6cd98..c6266693 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -91,8 +91,9 @@ private void Init( }; UseNamespaceInEntitySetName = useNamespaceInEntitySetName; - _container.RegisterInstance( - new DataObjectEdmModelDependencies(_container.IsRegistered() ? _container.Resolve() : null, + _container.RegisterType( + new InjectionConstructor( + _container.IsRegistered() ? _container.Resolve() : null, _container.IsRegistered("Export") ? _container.Resolve("Export") : null, _container.IsRegistered() ? _container.Resolve() : null, _container.IsRegistered("ExportStringedObjectView") ? _container.Resolve("ExportStringedObjectView") : null, From 3ade9b82b3a9679659c078d6d325fc40046626e4 Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 22:01:40 +0500 Subject: [PATCH 29/40] Try to fix github build --- .../BaseODataServiceIntegratedTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index c6266693..8563d034 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -11,6 +11,7 @@ using NewPlatform.Flexberry.ORM.ODataService.Tests.Helpers; using Unity; + using Unity.Injection; using Xunit; using Xunit.Abstractions; @@ -20,7 +21,6 @@ using NewPlatform.Flexberry.ORM.ODataService.Extensions; using NewPlatform.Flexberry.ORM.ODataService.WebApi.Extensions; using Unity.AspNet.WebApi; - using Unity.Injection; #endif #if NETCOREAPP using NewPlatform.Flexberry.ORM.ODataService.Routing; From 9109e48bef15b6d0a7377f05d8306ee1ccf0e275 Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 22:48:23 +0500 Subject: [PATCH 30/40] Try to fix github build --- .../BaseIntegratedTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index f8d3fa43..0f6caf4f 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -470,7 +470,7 @@ private static string ConnectionStringOracleDataSource private static string GetConnectionString(string name) { - return Environment.GetEnvironmentVariable(name) ?? ConfigurationManager.ConnectionStrings[name].ConnectionString; + return Environment.GetEnvironmentVariable(name) ?? (ConfigurationManager.ConnectionStrings[name] ?? throw new Exception($"No information about connection string with name {name}")).ConnectionString; } } } From 3eb082d0c53d03ba9f327716f4a6e206c0a7c953 Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 23:38:18 +0500 Subject: [PATCH 31/40] Repair of github build --- .github/workflows/build.yml | 2 +- .../XUnitTestRunnerInitializer.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76d2de8e..60afa263 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -153,7 +153,7 @@ jobs: run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln - name: Install xunit.runner.console - run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner + run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner -Source https://api.nuget.org/v3/index.json - name: Compile code run: dotnet build --no-restore -v q /p:WarningLevel=0 -c $CONFIGURATION NewPlatform.Flexberry.ORM.ODataService.sln diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs index 5dcb3482..4e726c23 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/XUnitTestRunnerInitializer.cs @@ -30,19 +30,19 @@ public class XUnitTestRunnerInitializer : XunitTestFramework public XUnitTestRunnerInitializer(IMessageSink messageSink) : base(messageSink) { +#if NETCOREAPP + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + string configFile = $"{Assembly.GetExecutingAssembly().Location}.config"; + string outputConfigFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath; + File.Copy(configFile, outputConfigFile, true); +#endif + IBusinessServerProvider businessServerProvider = new Mock().Object; IDataService ds = new MSSQLDataService(new Mock().Object, new Mock().Object, new Mock().Object); DataServiceProvider.DataService = ds; ExternalLangDef.LanguageDef = new ExternalLangDef(ds); DetailVariableDef.ViewGenerator = null; - -#if NETCOREAPP - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); - string configFile = $"{Assembly.GetExecutingAssembly().Location}.config"; - string outputConfigFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath; - File.Copy(configFile, outputConfigFile, true); -#endif } } } From 64c11f4a9c1f1cf88b6d9106715838f048abb282 Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 23:51:38 +0500 Subject: [PATCH 32/40] Fixed error on tests on net7 for github --- .../CustomWebApplicationFactory.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs index b80e7c7b..1720729f 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs @@ -4,7 +4,8 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using System; using System.IO; using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Mvc.Testing; + using Microsoft.AspNetCore.Mvc.Testing; + using Unity; using Unity.Microsoft.DependencyInjection; /// @@ -20,7 +21,7 @@ public class CustomWebApplicationFactory : WebApplicationFactory - public static Unity.IUnityContainer _unityContainer; + public static IUnityContainer _unityContainer; /// protected override IWebHostBuilder CreateWebHostBuilder() From ba5d6f81dc98a76b3ed7d3bf90e93646a0ed129f Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Mon, 5 Jun 2023 23:58:12 +0500 Subject: [PATCH 33/40] Changed nuget source for github actions --- .github/workflows/build.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60afa263..a93e69fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ on: env: XUNIT_RUNNER: "2.4.1" CONFIGURATION: "Debug" + NUPATH: "https://api.nuget.org/v3/index.json" # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -73,10 +74,10 @@ jobs: dotnet-version: 7.0.x - name: Restore NewPlatform.Flexberry.ORM.ODataService.sln - run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln + run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln -s $NUPATH - name: Install xunit.runner.console - run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner -Source https://api.nuget.org/v3/index.json + run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner -Source $NUPATH - name: Compile code run: dotnet build --no-restore -v q /p:WarningLevel=0 -c $CONFIGURATION NewPlatform.Flexberry.ORM.ODataService.sln @@ -150,10 +151,10 @@ jobs: dotnet-version: 7.0.x - name: Restore NewPlatform.Flexberry.ORM.ODataService.sln - run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln + run: dotnet restore NewPlatform.Flexberry.ORM.ODataService.sln -s $NUPATH - name: Install xunit.runner.console - run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner -Source https://api.nuget.org/v3/index.json + run: nuget install xunit.runner.console -Version $XUNIT_RUNNER -OutputDirectory testrunner -Source $NUPATH - name: Compile code run: dotnet build --no-restore -v q /p:WarningLevel=0 -c $CONFIGURATION NewPlatform.Flexberry.ORM.ODataService.sln From d77355380baadc7ed2d38519ba47e4bcfb87082b Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Tue, 6 Jun 2023 11:38:55 +0500 Subject: [PATCH 34/40] Fixed tests for net4.5 --- .../BaseODataServiceIntegratedTest.cs | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index 8563d034..a9af718d 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -90,16 +90,6 @@ private void Init( typeof(Car).Assembly, }; UseNamespaceInEntitySetName = useNamespaceInEntitySetName; - - _container.RegisterType( - new InjectionConstructor( - _container.IsRegistered() ? _container.Resolve() : null, - _container.IsRegistered("Export") ? _container.Resolve("Export") : null, - _container.IsRegistered() ? _container.Resolve() : null, - _container.IsRegistered("ExportStringedObjectView") ? _container.Resolve("ExportStringedObjectView") : null, - _container.IsRegistered() ? _container.Resolve() : null, - _container.IsRegistered("Export") ? _container.Resolve("Export") : null)); - _builder = new DefaultDataObjectEdmModelBuilder(DataObjectsAssembliesNames, _serviceProvider, UseNamespaceInEntitySetName, pseudoDetailDefinitions); } @@ -135,24 +125,35 @@ public virtual void ActODataService(Action action) foreach (IDataService dataService in DataServices) { + // Здесь создаётся отдельный контейнер, поскольку он идёт в UnityDependencyResolver, где позднее уходит на Dispose. + using (var container = new UnityContainer()) using (var config = new HttpConfiguration()) using (var server = new HttpServer(config)) using (var client = new HttpClient(server, false) { BaseAddress = new Uri("http://localhost/odata/") }) { - _container.RegisterInstance(dataService); + container.RegisterType( + new InjectionConstructor( + container.IsRegistered() ? container.Resolve() : null, + container.IsRegistered("Export") ? container.Resolve("Export") : null, + container.IsRegistered() ? container.Resolve() : null, + container.IsRegistered("ExportStringedObjectView") ? container.Resolve("ExportStringedObjectView") : null, + container.IsRegistered() ? container.Resolve() : null, + container.IsRegistered("Export") ? container.Resolve("Export") : null)); + container.RegisterInstance(dataService); server.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; config.EnableCors(new EnableCorsAttribute("*", "*", "*")); - config.DependencyResolver = new UnityDependencyResolver(_container); + + config.DependencyResolver = new UnityDependencyResolver(container); const string fileControllerPath = "api/File"; config.MapODataServiceFileRoute("File", fileControllerPath); var fileAccessor = new DefaultDataObjectFileAccessor(new Uri("http://localhost/"), fileControllerPath, "Uploads"); - _container.RegisterInstance(fileAccessor); + container.RegisterInstance(fileAccessor); var token = config.MapDataObjectRoute(_builder, server, "odata", "odata", true); token.Events.CallbackAfterInternalServerError = AfterInternalServerError; - var args = new TestArgs { UnityContainer = _container, DataService = dataService, HttpClient = client, Token = token }; + var args = new TestArgs { UnityContainer = container, DataService = dataService, HttpClient = client, Token = token }; action(args); } } From 189ae0e8286db8067628df7e77771251ea6e61eb Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Tue, 6 Jun 2023 14:22:13 +0500 Subject: [PATCH 35/40] Moving of serviceprovider creation --- .../BaseODataServiceIntegratedTest.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index a9af718d..2d0cf52d 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -20,19 +20,17 @@ using System.Web.Http.Cors; using NewPlatform.Flexberry.ORM.ODataService.Extensions; using NewPlatform.Flexberry.ORM.ODataService.WebApi.Extensions; - using Unity.AspNet.WebApi; + using Unity.AspNet.WebApi; #endif #if NETCOREAPP using NewPlatform.Flexberry.ORM.ODataService.Routing; #endif - + /// /// Базовый класс для тестирования работы с данными через ODataService. /// public class BaseODataServiceIntegratedTest : BaseIntegratedTest { - protected IDataObjectEdmModelBuilder _builder; - public class TestArgs { public IUnityContainer UnityContainer { get; set; } @@ -54,6 +52,8 @@ public class TestArgs /// public bool UseNamespaceInEntitySetName { get; protected set; } + private PseudoDetailDefinitions pseudoDetailDefinitions; + #if NETFRAMEWORK public BaseODataServiceIntegratedTest( string stageCasePath = @"РТЦ Тестирование и документирование\Модели для юнит-тестов\Flexberry ORM\NewPlatform.Flexberry.ORM.ODataService.Tests\", @@ -90,7 +90,7 @@ private void Init( typeof(Car).Assembly, }; UseNamespaceInEntitySetName = useNamespaceInEntitySetName; - _builder = new DefaultDataObjectEdmModelBuilder(DataObjectsAssembliesNames, _serviceProvider, UseNamespaceInEntitySetName, pseudoDetailDefinitions); + this.pseudoDetailDefinitions = pseudoDetailDefinitions; } /// @@ -126,10 +126,10 @@ public virtual void ActODataService(Action action) foreach (IDataService dataService in DataServices) { // Здесь создаётся отдельный контейнер, поскольку он идёт в UnityDependencyResolver, где позднее уходит на Dispose. - using (var container = new UnityContainer()) - using (var config = new HttpConfiguration()) - using (var server = new HttpServer(config)) - using (var client = new HttpClient(server, false) { BaseAddress = new Uri("http://localhost/odata/") }) + using (UnityContainer container = new UnityContainer()) + using (HttpConfiguration config = new HttpConfiguration()) + using (HttpServer server = new HttpServer(config)) + using (HttpClient client = new HttpClient(server, false) { BaseAddress = new Uri("http://localhost/odata/") }) { container.RegisterType( new InjectionConstructor( @@ -143,7 +143,7 @@ public virtual void ActODataService(Action action) server.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; config.EnableCors(new EnableCorsAttribute("*", "*", "*")); - + config.DependencyResolver = new UnityDependencyResolver(container); const string fileControllerPath = "api/File"; @@ -151,7 +151,9 @@ public virtual void ActODataService(Action action) var fileAccessor = new DefaultDataObjectFileAccessor(new Uri("http://localhost/"), fileControllerPath, "Uploads"); container.RegisterInstance(fileAccessor); - var token = config.MapDataObjectRoute(_builder, server, "odata", "odata", true); + IServiceProvider serviceProvider = new ICSSoft.Services.UnityServiceProvider(container); + DefaultDataObjectEdmModelBuilder builder = new DefaultDataObjectEdmModelBuilder(DataObjectsAssembliesNames, serviceProvider, UseNamespaceInEntitySetName, pseudoDetailDefinitions); + var token = config.MapDataObjectRoute(builder, server, "odata", "odata", true); token.Events.CallbackAfterInternalServerError = AfterInternalServerError; var args = new TestArgs { UnityContainer = container, DataService = dataService, HttpClient = client, Token = token }; action(args); From b2a4b10c131b72d925af715377264ca5a97e27cf Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:19:18 +0500 Subject: [PATCH 36/40] Remove nuget.config --- NewPlatform.Flexberry.ORM.ODataService.sln | 1 - NuGet.config | 7 ------- 2 files changed, 8 deletions(-) delete mode 100644 NuGet.config diff --git a/NewPlatform.Flexberry.ORM.ODataService.sln b/NewPlatform.Flexberry.ORM.ODataService.sln index 596894be..c68306bd 100644 --- a/NewPlatform.Flexberry.ORM.ODataService.sln +++ b/NewPlatform.Flexberry.ORM.ODataService.sln @@ -25,7 +25,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Open Source", "Open Source" CHANGELOG.md = CHANGELOG.md ConfigTuner.ps1 = ConfigTuner.ps1 LICENSE.md = LICENSE.md - NuGet.config = NuGet.config README.md = README.md EndProjectSection EndProject diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index a157bfd8..00000000 --- a/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file From 2fcfef00c335a64859b73e43f6b7132622bf90e0 Mon Sep 17 00:00:00 2001 From: Anisimova2020 <70688166+Anisimova2020@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:44:47 +0500 Subject: [PATCH 37/40] Updated version of NewPlatform.Flexberry.ORM.ODataService up to 7.2.0-alpha01 --- CHANGELOG.md | 8 ++++++-- LICENSE.md | 2 +- NewPlatform.Flexberry.ORM.ODataService.nuspec | 17 +++++++++-------- .../Model/DefaultDataObjectEdmModelBuilder.cs | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ca34b78..845acb20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,16 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +1. Helper class `DataObjectEdmModelDependencies` (it helps send named settings of Unity to class `DataObjectEdmModel`). ### Changed -1. Updated `NewPlatform.Flexberry.ORM` up to `7.1.1-beta01`. +1. Updated `NewPlatform.Flexberry.ORM` up to `7.2.0-alpha02`. +2. Constructor of class `DataObjectEdmModel` (it now needs extra DI initialization). +3. Constructor of class `DefaultDataObjectEdmModelBuilder` (it is factory for class `DataObjectEdmModel`). +4. Constructor of class `DefaultOfflineManager`. +5. Constructor of class `OfflineAuditService`. ### Fixed -1. Fixed problem with metadata when inheritance and PublishName is used. ## [7.1.0] - 2023.04.12 diff --git a/LICENSE.md b/LICENSE.md index cee2b214..60b91704 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 Flexberry PLATFORM +Copyright (c) 2023 Flexberry PLATFORM Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/NewPlatform.Flexberry.ORM.ODataService.nuspec b/NewPlatform.Flexberry.ORM.ODataService.nuspec index ba4452b3..548bd86f 100644 --- a/NewPlatform.Flexberry.ORM.ODataService.nuspec +++ b/NewPlatform.Flexberry.ORM.ODataService.nuspec @@ -2,7 +2,7 @@ NewPlatform.Flexberry.ORM.ODataService - 7.1.1-beta03 + 7.2.0-alpha01 Flexberry ORM ODataService New Platform Ltd. New Platform Ltd. @@ -12,14 +12,15 @@ true Flexberry ORM OData Service Package. - Changed - 1. Updated `NewPlatform.Flexberry.ORM` up to `7.1.1-beta01`. - 2. Get properties from objects for send it to frontend always rethrow exception now. + Added + 1. Helper class `DataObjectEdmModelDependencies` (it helps send named settings of Unity to class `DataObjectEdmModel`). - Fixed - 1. Fixed problem with metadata when inheritance and PublishName is used. - 2. Safe load details with complex type usage hierarchy. - + Changed + 1. Updated `NewPlatform.Flexberry.ORM` up to `7.2.0-alpha02`. + 2. Constructor of class `DataObjectEdmModel` (it now needs extra DI initialization). + 3. Constructor of class `DefaultDataObjectEdmModelBuilder` (it is factory for class `DataObjectEdmModel`). + 4. Constructor of class `DefaultOfflineManager`. + 5. Constructor of class `OfflineAuditService`. Copyright New Platform Ltd 2023 Flexberry ORM OData ODataService diff --git a/NewPlatform.Flexberry.ORM.ODataService/Model/DefaultDataObjectEdmModelBuilder.cs b/NewPlatform.Flexberry.ORM.ODataService/Model/DefaultDataObjectEdmModelBuilder.cs index d48ae351..c2530455 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Model/DefaultDataObjectEdmModelBuilder.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Model/DefaultDataObjectEdmModelBuilder.cs @@ -119,7 +119,7 @@ public DataObjectEdmModel Build() var typeFilter = TypeFilter ?? (t => true); - foreach (Assembly assembly in _searchAssemblies.Where(x => !x.FullName.Contains("UserSettingsService"))) + foreach (Assembly assembly in _searchAssemblies) { IEnumerable dataObjectTypes = assembly .GetTypes() From 34710f55c4e5033508c18f51d1ec5a9cfe7ed565 Mon Sep 17 00:00:00 2001 From: Ilya Naidanov Date: Fri, 29 Mar 2024 15:50:31 +0500 Subject: [PATCH 38/40] =?UTF-8?q?=D0=93=D0=B5=D0=BD=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=20testhost.?= =?UTF-8?q?dll.config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewPlatform.Flexberry.ORM.ODataService.Tests.csproj | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/NewPlatform.Flexberry.ORM.ODataService.Tests.csproj b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/NewPlatform.Flexberry.ORM.ODataService.Tests.csproj index 8dbeab6f..049a0f4b 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/NewPlatform.Flexberry.ORM.ODataService.Tests.csproj +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/NewPlatform.Flexberry.ORM.ODataService.Tests.csproj @@ -21,7 +21,7 @@ - + all @@ -60,7 +60,7 @@ - + @@ -138,4 +138,9 @@ + + + + + From 40608e0323fbdb19eee3b2e93a5cc7b5ceb835b4 Mon Sep 17 00:00:00 2001 From: inaidanov Date: Fri, 29 Mar 2024 19:18:57 +0500 Subject: [PATCH 39/40] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D1=87=D0=B0=20UnityContainer=20=D0=B2=20=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseIntegratedTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index 2cd05e1c..ab2301e1 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -170,6 +170,8 @@ protected BaseIntegratedTest(CustomWebApplicationFactory factory, ITes businessServerProvider = _container.Resolve(); #if NETCOREAPP CustomWebApplicationFactory._unityContainer = _container; + CustomWebApplicationFactory._unityContainer = _container; + CustomWebApplicationFactory._unityContainer = _container; _output = output; From 5ef36ba73b8e5a67784637aafa0a0acb9fcaa497 Mon Sep 17 00:00:00 2001 From: inaidanov Date: Fri, 26 Apr 2024 22:21:33 +0500 Subject: [PATCH 40/40] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20unityContain?= =?UTF-8?q?er=20=D0=B2=20=D1=82=D0=B5=D1=81=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseIntegratedTest.cs | 7 ++---- .../BaseODataServiceIntegratedTest.cs | 7 ++++-- .../CustomWebApplicationFactory.cs | 18 +++---------- .../Startup.cs | 1 + .../Startups/UpdateViewsTestStartup.cs | 23 +++-------------- .../TestStartup.cs | 25 ++++--------------- 6 files changed, 20 insertions(+), 61 deletions(-) diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index ab2301e1..eabedb3e 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -37,7 +37,7 @@ public abstract class BaseIntegratedTest : IDisposable /// /// Startup class used for booting the application. public abstract class BaseIntegratedTest : IClassFixture>, IDisposable - where TStartup : class + where TStartup : Startup { protected readonly WebApplicationFactory _factory; #endif @@ -160,18 +160,15 @@ protected BaseIntegratedTest(CustomWebApplicationFactory factory, ITes { _factory = factory; #endif - _container = new UnityContainer(); #if NETCOREAPP + _container = _factory.Services.GetService(typeof(IUnityContainer)) as IUnityContainer; _container.LoadConfiguration(); #endif _serviceProvider = new UnityServiceProvider(_container); _container.RegisterFactory(new Func(o => new BusinessServerProvider(new UnityServiceProvider(o))), FactoryLifetime.Singleton); businessServerProvider = _container.Resolve(); #if NETCOREAPP - CustomWebApplicationFactory._unityContainer = _container; - CustomWebApplicationFactory._unityContainer = _container; - CustomWebApplicationFactory._unityContainer = _container; _output = output; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index af0f1652..d45abac9 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs @@ -24,6 +24,9 @@ #endif #if NETCOREAPP using NewPlatform.Flexberry.ORM.ODataService.Routing; + using System.ComponentModel; + using ODataServiceSample.AspNetCore; + using Microsoft.AspNetCore.Builder; #endif /// @@ -34,7 +37,7 @@ public class BaseODataServiceIntegratedTest : BaseIntegratedTest #endif #if NETCOREAPP public class BaseODataServiceIntegratedTest : BaseIntegratedTest - where TStartup : class + where TStartup : Startup #endif { public class TestArgs @@ -186,7 +189,7 @@ public virtual void ActODataService(Action action) // Add "/odata/" postfix. client.BaseAddress = new Uri(client.BaseAddress, DataObjectRoutingConventions.DefaultRouteName + "/"); - IUnityContainer container = TestStartup._unityContainer; // При создании odata-приложения оригинальный контейнер не изменяется. + IUnityContainer container = _container; // При создании odata-приложения оригинальный контейнер не изменяется. ManagementToken token = (ManagementToken)container.Resolve(typeof(ManagementToken)); container.RegisterInstance(dataService); token.Events.CallbackAfterInternalServerError = AfterInternalServerError; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs index b875da11..3b4fe079 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CustomWebApplicationFactory.cs @@ -5,6 +5,7 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using System.IO; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; + using ODataServiceSample.AspNetCore; using Unity; using Unity.Microsoft.DependencyInjection; @@ -13,27 +14,14 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests /// /// Startup type. public class CustomWebApplicationFactory : WebApplicationFactory - where TStartup : class + where TStartup : Startup { - /// - /// Unity container is created in only one place: . - /// Further, it autimatically appears in a child , where ODataService starts. - /// The service is started in this class. Therefore, the Unity container must be passed to the running application here, - /// being initialized earlier. - /// - public static IUnityContainer _unityContainer; - /// protected override IWebHostBuilder CreateWebHostBuilder() { - if (_unityContainer == null) - { - throw new Exception("Unity.IUnityContainer is not defined"); - } - string contentRootDirectory = Directory.GetCurrentDirectory(); var webHostBuilder = new WebHostBuilder() - .UseUnityServiceProvider(_unityContainer) + .UseUnityServiceProvider() .UseContentRoot(contentRootDirectory) .UseStartup(); return webHostBuilder; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs index f3a62011..d1548525 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startup.cs @@ -50,6 +50,7 @@ public Startup(IConfiguration configuration) public virtual void ConfigureContainer(IUnityContainer unityContainer) { // Configure Flexberry services via Unity. + unityContainer.RegisterFactory(new Func(o => new BusinessServerProvider(new UnityServiceProvider(o))), FactoryLifetime.Singleton); var securityManager = new EmptySecurityManager(); Mock mockAuditService = new Mock(); IBusinessServerProvider businessServerProvider = unityContainer.Resolve(); diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startups/UpdateViewsTestStartup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startups/UpdateViewsTestStartup.cs index 3ec2f447..42992309 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startups/UpdateViewsTestStartup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Startups/UpdateViewsTestStartup.cs @@ -10,6 +10,7 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.DependencyInjection; using NewPlatform.Flexberry.ORM.ODataService; using NewPlatform.Flexberry.ORM.ODataService.Extensions; using NewPlatform.Flexberry.ORM.ODataService.Model; @@ -24,13 +25,6 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests /// public class UpdateViewsTestStartup : Startup { - /// - /// After the start of the OData app, the container in the OData app is its own. - /// Therefore, a static field is defined here, so that later this container can be pulled back. - /// - /// - public static IUnityContainer _unityContainer; - /// /// Initialize new instance of TestStartup. /// @@ -40,21 +34,12 @@ public UpdateViewsTestStartup(IConfiguration configuration) { } - /// - /// Method for Unity container configuring. - /// - /// Unity container. - public override void ConfigureContainer(IUnityContainer unityContainer) - { - _unityContainer = unityContainer; - base.ConfigureContainer(unityContainer); - } - /// public override void Configure(IApplicationBuilder app, IHostingEnvironment env) { IServiceProvider serviceProvider = app.ApplicationServices; - _unityContainer.RegisterInstance(env); + IUnityContainer unityContainer = serviceProvider.GetRequiredService(); + unityContainer.RegisterInstance(env); app.UseMiddleware(); @@ -84,7 +69,7 @@ public override void Configure(IApplicationBuilder app, IHostingEnvironment env) var token = builder.MapDataObjectRoute(modelBuilder); - _unityContainer.RegisterInstance(typeof(ManagementToken), token); + unityContainer.RegisterInstance(typeof(ManagementToken), token); }); } } diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs index 9978e1cd..a4637258 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestStartup.cs @@ -7,7 +7,8 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Routing; - using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.DependencyInjection; using NewPlatform.Flexberry.ORM.ODataService; using NewPlatform.Flexberry.ORM.ODataService.Extensions; using NewPlatform.Flexberry.ORM.ODataService.Model; @@ -21,13 +22,6 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests ///
public class TestStartup : Startup { - /// - /// After the start of the OData app, the container in the OData app is its own. - /// Therefore, a static field is defined here, so that later this container can be pulled back. - /// - /// - public static IUnityContainer _unityContainer; - /// /// Initialize new instance of TestStartup. /// @@ -36,22 +30,13 @@ public TestStartup(IConfiguration configuration) : base(configuration) { } - - /// - /// Method for Unity container configuring. - /// - /// Unity container. - public override void ConfigureContainer(IUnityContainer unityContainer) - { - _unityContainer = unityContainer; - base.ConfigureContainer(unityContainer); - } /// public override void Configure(IApplicationBuilder app, IHostingEnvironment env) { IServiceProvider serviceProvider = app.ApplicationServices; - _unityContainer.RegisterInstance(env); + IUnityContainer unityContainer = serviceProvider.GetRequiredService(); + unityContainer.RegisterInstance(env); app.UseMiddleware(); @@ -76,7 +61,7 @@ public override void Configure(IApplicationBuilder app, IHostingEnvironment env) var token = builder.MapDataObjectRoute(modelBuilder); - _unityContainer.RegisterInstance(typeof(ManagementToken), token); + unityContainer.RegisterInstance(typeof(ManagementToken), token); }); } }