private static void ConfigureSQLDataBase(this IServiceCollection services, IConfiguration DirectoryConfiguration)
        {
            bool   clearDBOnStart = DirectoryConfiguration.ReadBoolProperty(ClearDbOnStartPropertyName);
            bool   addTestData    = DirectoryConfiguration.ReadBoolProperty(AddTestDataPropertyName);
            string connection     = DirectoryConfiguration.GetConnectionString(ConnectionPropertyName);

            var options = new DbContextOptionsBuilder <ApplicationContext>()
                          .UseSqlServer(connection)
                          .Options;

            services.AddScoped(typeof(IOrderDirectoryServise),
                               (servProvider) =>
                               new EntityUserOrderDirectory(new ApplicationContext(options)));
            services.AddScoped(typeof(IUserDirectoryServise),
                               (servProvider) =>
                               new EntityUserOrderDirectory(new ApplicationContext(options)));

            if (addTestData)
            {
                ApplicationContext applicationContext = new ApplicationContext(options, clearDBOnStart);
                var directoryService = new EntityUserOrderDirectory(applicationContext);
                var testData         = new TestDataFiller(directoryService, directoryService);
                testData.FillIfEmpty();
            }
            else if (clearDBOnStart)
            {
                new ApplicationContext(options, clearDBOnStart);
            }
        }
Exemple #2
0
 public void TestInitialize()
 {
     _tldc = new TestLocalDataContext();
     TestDataFiller.Fill(_tldc);
     _testDataService = new TestDataService(_tldc);
     _dataContext     = new DataContext(_testDataService);
 }
Exemple #3
0
        public void TestInitialize()
        {
            IDepartment department = new TestDepartment();

            TestLocalDataContext _tldc = new TestLocalDataContext();

            TestDataFiller.Fill(_tldc);

            ITestDataService _testDataService = new TestDataService(_tldc);
            IDataContext     _dataContext     = new DataContext(_testDataService);

            _mainWindowViewModel = new MainWindowViewModel(_dataContext, department);
        }
        private static void ConfigureInMemoryDataBase(this IServiceCollection services, IConfiguration DirectoryConfiguration)
        {
            var directoryService = new MemoryUserOrderDirectory();

            services.AddSingleton(typeof(IOrderDirectoryServise), directoryService);
            services.AddSingleton(typeof(IUserDirectoryServise), directoryService);

            bool addTestData = DirectoryConfiguration.ReadBoolProperty(AddTestDataPropertyName);

            if (addTestData)
            {
                var testData = new TestDataFiller(directoryService, directoryService);
                testData.FillIfEmpty();
            }
        }