diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs index 731157a8..ea70ffdd 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseIntegratedTest.cs @@ -17,6 +17,8 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Tests using Oracle.ManagedDataAccess.Client; using Xunit; using Xunit.Abstractions; + using Unity; + using ICSSoft.Services; #if NETFRAMEWORK /// @@ -28,16 +30,15 @@ public abstract class BaseIntegratedTest : IDisposable #if NETCOREAPP using Microsoft.AspNetCore.Mvc.Testing; using ODataServiceSample.AspNetCore; - using ICSSoft.Services; - using Unity; /// /// Base class for integration tests. /// - public abstract class BaseIntegratedTest : IClassFixture>, IDisposable + public abstract class BaseIntegratedTest : IClassFixture, IDisposable { protected readonly WebApplicationFactory _factory; #endif + protected readonly IUnityContainer _container; /// /// Provider for injection to data services for test purposes. /// @@ -155,6 +156,7 @@ public void Dispose() /// Use DataService with Gis support. protected BaseIntegratedTest(string tempDbNamePrefix, bool useGisDataService = false) { + _container = UnityFactory.GetContainer(); #endif #if NETCOREAPP /// @@ -164,15 +166,20 @@ protected BaseIntegratedTest(string tempDbNamePrefix, bool useGisDataService = f /// Unit tests debug output. /// Prefix for temp database name. /// Use DataService with Gis support. - protected BaseIntegratedTest(CustomWebApplicationFactory factory, ITestOutputHelper output, string tempDbNamePrefix, bool useGisDataService = false) + protected BaseIntegratedTest(TestFixtureData fixtureData, ITestOutputHelper output, string tempDbNamePrefix, bool useGisDataService = false) { - _factory = factory; + if (fixtureData == null) + { + throw new ArgumentNullException(nameof(fixtureData)); + } + + _factory = fixtureData.factory; + _container = fixtureData.unityContainer; _output = output; if (output != null) { - IUnityContainer container = UnityFactory.GetContainer(); - container.RegisterInstance(_output); + _container.RegisterInstance(_output); } #endif _useGisDataService = useGisDataService; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/BaseODataServiceIntegratedTest.cs index 03344faf..a2c9e0f3 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(CustomWebApplicationFactory factory, ITestOutputHelper output = null, bool useNamespaceInEntitySetName = false, bool useGisDataService = false, PseudoDetailDefinitions pseudoDetailDefinitions = null) - : base(factory, output, "ODataDB", useGisDataService) + public BaseODataServiceIntegratedTest(TestFixtureData fixtureData, ITestOutputHelper output = null, bool useNamespaceInEntitySetName = false, bool useGisDataService = false, PseudoDetailDefinitions pseudoDetailDefinitions = null) + : base(fixtureData, output, "ODataDB", useGisDataService) { Init(useNamespaceInEntitySetName, pseudoDetailDefinitions); } @@ -98,12 +98,11 @@ private void Init( /// Исключение, которое возникло внутри ODataService. /// Возвращаемый код HTTP. По-умолчанияю 500. /// Исключение, которое будет отправлено клиенту. - public static Exception AfterInternalServerError(Exception e, ref HttpStatusCode code) + public Exception AfterInternalServerError(Exception e, ref HttpStatusCode code) { - IUnityContainer container = UnityFactory.GetContainer(); - if (container.IsRegistered()) + if (_container.IsRegistered()) { - ITestOutputHelper output = container.Resolve(); + ITestOutputHelper output = _container.Resolve(); output.WriteLine(e.ToString()); } @@ -168,16 +167,14 @@ public virtual void ActODataService(Action action) // Add "/odata/" postfix. client.BaseAddress = new Uri(client.BaseAddress, DataObjectRoutingConventions.DefaultRouteName + "/"); - IUnityContainer container = UnityFactory.GetContainer(); - - ManagementToken token = (ManagementToken)container.Resolve(typeof(ManagementToken)); - container.RegisterInstance(dataService); + 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 6f1bfb16..d654a0d4 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public BusinessServersTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 a340a454..1b65fac9 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public ChangeMasterInBSTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 f1aedc2b..e0ad87ae 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) : base(factory, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) + public CreateWithPseudoDetailDefinedTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) : base(fixtureData, 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 c3e7bbf0..c10588b8 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(CustomWebApplicationFactory factory, ITestOutputHelper output) - : base(factory, output, false, true) + public GisCRUDTest(TestFixtureData fixtureData, ITestOutputHelper output) + : base(fixtureData, 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 5cf8b22a..1656afd8 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public MultiThreadTests(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, output) { } #endif @@ -71,15 +71,8 @@ public void CreateTest() ActODataService( args => { - // Arrange. - IUnityContainer container; -#if NETFRAMEWORK - container = UnityFactory.GetContainer(); -#elif NETCOREAPP - container = args.UnityContainer; -#endif - RegisterCustomUser(container); - ICurrentUser currentUser = container.Resolve(); + RegisterCustomUser(_container); + ICurrentUser currentUser = _container.Resolve(); // Регистрация событий. args.Token.Events.CallbackBeforeCreate = dobj => @@ -126,11 +119,7 @@ public void ReadTest() args => { // Arrange. -#if NETFRAMEWORK - RegisterCustomUser(UnityFactory.GetContainer()); -#elif NETCOREAPP - RegisterCustomUser(args.UnityContainer); -#endif + RegisterCustomUser(_container); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[ThreadCount]; @@ -170,14 +159,8 @@ public void UpdateTest() args => { // Arrange. - IUnityContainer container; -#if NETFRAMEWORK - container = UnityFactory.GetContainer(); -#elif NETCOREAPP - container = args.UnityContainer; -#endif - RegisterCustomUser(container); - ICurrentUser currentUser = container.Resolve(); + RegisterCustomUser(_container); + ICurrentUser currentUser = _container.Resolve(); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[ThreadCount]; @@ -233,14 +216,8 @@ public void DeleteTest() args => { // Arrange. - IUnityContainer container; -#if NETFRAMEWORK - container = UnityFactory.GetContainer(); -#elif NETCOREAPP - container = args.UnityContainer; -#endif - RegisterCustomUser(container); - ICurrentUser currentUser = container.Resolve(); + RegisterCustomUser(_container); + ICurrentUser currentUser = _container.Resolve(); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[ThreadCount]; @@ -302,14 +279,8 @@ public void BatchTest() args => { // Arrange. - IUnityContainer container; -#if NETFRAMEWORK - container = UnityFactory.GetContainer(); -#elif NETCOREAPP - container = args.UnityContainer; -#endif - RegisterCustomUser(container); - ICurrentUser currentUser = container.Resolve(); + RegisterCustomUser(_container); + ICurrentUser currentUser = _container.Resolve(); // Регистрация событий. args.Token.Events.CallbackBeforeUpdate = dobj => 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 350dda1a..cb1338ab 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public BuiltinQueryFunctionsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 9eabb8aa..33935650 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public ExcelExportTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 eab57c08..5e2e840b 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public FilterByMasterDetailFieldTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 283adb51..74fcc413 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public FilterByMasterFieldTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 c7421e20..96268e85 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public FilterByMasterMasterDetailFieldTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 01361214..e2608bfb 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/CRUD/Read/FilterByPseudoDetailFieldTest.cs @@ -36,11 +36,10 @@ public FilterByPseudoDetailFieldTest() : base(pseudoDetailDefinitions: GetPseudo } #endif #if NETCOREAPP - public FilterByPseudoDetailFieldTest(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) + public FilterByPseudoDetailFieldTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, output, pseudoDetailDefinitions: GetPseudoDetailDefinitions()) { - IUnityContainer container = UnityFactory.GetContainer(); - container.RegisterInstance(GetPseudoDetailDefinitions()); + _container.RegisterInstance(GetPseudoDetailDefinitions()); } #endif 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 8bff97a0..3e00c170 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public FilterTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 3f388322..f2a72d75 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public MetaDataTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 ecbed583..021e2a22 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public ReferenceToMasterTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 fafca5aa..e2af17ce 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(CustomWebApplicationFactory factory, ITestOutputHelper output) - : base(factory, output) + public SkipTopOrderByTest(TestFixtureData fixtureData, ITestOutputHelper output) + : base(fixtureData, 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 931f1a75..a2a627c5 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public UtfRequestsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 d4077833..2b3351b5 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public BusinessServersTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 ab44a57e..d48ab800 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public ModifyDataTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 708d2bb5..3e5409f7 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public WebFileTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, output) { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs index 4e108989..25bb79fc 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public AfterGetTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 428eccb4..a8caf46d 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public AfterInternalServerErrorTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 52d93515..bce04edc 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public AfterSaveTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 5644de97..b9eb79d1 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public BeforeGetTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 153301b1..717a9332 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public BeforeSaveTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 9ba02a91..092a8cc1 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public FileControllerTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 f5431b2a..ce2a261f 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public ActionsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 f18e1521..e12aa76a 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public DelegateFunctionsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 a43b8ef3..277503cd 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public FunctionsTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, output) { } #endif @@ -47,7 +47,7 @@ public FunctionsTest(CustomWebApplicationFactory /// Container of user functions. /// Сервис данных. - public void RegisterODataUserFunctions(IFunctionContainer container, IDataService dataService) + public void RegisterODataUserFunctions(IFunctionContainer container, IDataService dataService, IUnityContainer unityContainer) { Dictionary parametersTypes = new Dictionary(); @@ -61,8 +61,7 @@ public void RegisterODataUserFunctions(IFunctionContainer container, IDataServic var type = queryParameters.GetDataObjectType(parameters["entitySet"] as string); var lcs = queryParameters.CreateLcs(type); #if NETCOREAPP - IUnityContainer container = UnityFactory.GetContainer(); - dataService = container.Resolve(); + dataService = unityContainer.Resolve(); #endif var dobjs = dataService.LoadObjects(lcs); return dobjs.AsEnumerable(); @@ -82,8 +81,7 @@ public void RegisterODataUserFunctions(IFunctionContainer container, IDataServic var uri = $"http://a/b/c?{parameters["query"]}"; var lcs = queryParameters.CreateLcs(type, uri); #if NETCOREAPP - IUnityContainer container = UnityFactory.GetContainer(); - dataService = container.Resolve(); + dataService = unityContainer.Resolve(); #endif var dobjs = dataService.LoadObjects(lcs); return dobjs.Length; @@ -128,8 +126,7 @@ public void RegisterODataUserFunctions(IFunctionContainer container, IDataServic (queryParameters, parameters) => { #if NETCOREAPP - IUnityContainer container = UnityFactory.GetContainer(); - dataService = container.Resolve(); + dataService = unityContainer.Resolve(); #endif var result = (dataService as SQLDataService).Query<Страна>(Страна.Views.СтранаE).ToArray(); return result[(int)parameters["intParam"]]; @@ -147,8 +144,7 @@ public void RegisterODataUserFunctions(IFunctionContainer container, IDataServic { var top = (int)parameters["intParam"]; #if NETCOREAPP - IUnityContainer container = UnityFactory.GetContainer(); - dataService = container.Resolve(); + dataService = unityContainer.Resolve(); #endif var result = (dataService as SQLDataService).Query<Страна>(Страна.Views.СтранаE).Take(top).ToArray(); queryParameters.Count = result.Length; @@ -166,8 +162,7 @@ public void RegisterODataUserFunctions(IFunctionContainer container, IDataServic (queryParameters, parameters) => { #if NETCOREAPP - IUnityContainer container = UnityFactory.GetContainer(); - dataService = container.Resolve(); + dataService = unityContainer.Resolve(); #endif var result = (dataService as SQLDataService).Query<Медведь>(Медведь.Views.МедведьE).ToArray(); return result[(int)parameters["intParam"]]; @@ -216,7 +211,7 @@ public void TestFunctionEnum() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); // Формируем URL запроса к OData-сервису. string requestUrl = $"http://localhost/odata/FunctionEnum(пол=NewPlatform.Flexberry.ORM.ODataService.Tests.tПол'Мужской')"; @@ -247,7 +242,7 @@ public void TestFunctionFunctionWithLcs() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[5]; @@ -307,7 +302,7 @@ public void TestSelectExpandFunctionEntity() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); Медведь медв = new Медведь { Вес = 48 }; Лес лес1 = new Лес { Название = "Бор" }; @@ -356,7 +351,7 @@ public void TestFunctionBinary() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); // Формируем URL запроса к OData-сервису. string requestUrl = $"http://localhost/odata/FunctionBinary()"; @@ -385,7 +380,7 @@ public void TestFunctionEntity() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[5]; @@ -429,7 +424,7 @@ public void TestCountFunctionEntitiesCollection() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[5]; @@ -480,7 +475,7 @@ public void TestFunctionEntitiesCollection() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); // Создаем объекты и кладем их в базу данных. DataObject[] countries = new DataObject[5]; @@ -523,7 +518,7 @@ public void TestFunctionsPrimitiveValuesTest() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); string returnValueString = "123456фывап"; @@ -577,7 +572,7 @@ public void TestFunctionHttpResponseException() { ActODataService(args => { - RegisterODataUserFunctions(args.Token.Functions, args.DataService); + RegisterODataUserFunctions(args.Token.Functions, args.DataService, args.UnityContainer); // Формируем URL запроса к OData-сервису. string requestUrl = $"http://localhost/odata/FunctionHttpResponseException()"; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Model/CustomizationEdmModelNames.cs index 0b8b0703..d21e6709 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + /// Данные для теста. + public CustomizationEdmModelNames(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 debbe59b..14ecd211 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(CustomWebApplicationFactory factory, Xunit.Abstractions.ITestOutputHelper output) - : base(factory, output) + public DefaultOfflineManagerIntegratedTest(TestFixtureData fixtureData, Xunit.Abstractions.ITestOutputHelper output) + : base(fixtureData, 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 9c9001e1..f69bcbea 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(CustomWebApplicationFactory factory, ITestOutputHelper output) - : base(factory, output, "offline") + public OfflineAuditServiceIntegratedTest(TestFixtureData fixtureData, ITestOutputHelper output) + : base(fixtureData, output, "offline") { } #endif diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestFixtureData.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestFixtureData.cs new file mode 100644 index 00000000..25d4b6ee --- /dev/null +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/TestFixtureData.cs @@ -0,0 +1,33 @@ +#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