示例#1
0
 private PCExpertModel LoadModel(EfWorkplace workplace)
 {
     return(new PCExpertModel
     {
         Interfaces = workplace.Query <ComponentInterface>().ToList(),
         Components = workplace.Query <PCComponent>().ToList(),
         Configurations = workplace.Query <PCConfiguration>().ToList(),
         Characteristics = workplace.Query <ComponentCharacteristic>().ToList()
     });
 }
示例#2
0
        public void DbOperationsTest()
        {
            var dbContextProvider = TestContextCreator.Create();

            using (var dbContext = dbContextProvider.DbContext)
            {
                var workplace  = new EfWorkplace(dbContextProvider);
                var savedModel = _testDataGenerator.CreateRandomData(workplace);
                dbContext.SaveChanges();

                var loadedModel = LoadModel(workplace);

                AssertModelsAreEqual(savedModel, loadedModel);
            }
        }
示例#3
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Initializing DB structure...");
            using (var context = new PCExpertContext("dbToFill",
                                                     new DropCreateDatabaseAlways <PCExpertContext>(),
                                                     new DomainValidatorFactory()))
            {
                Console.WriteLine("DB structure initialized");
                Console.WriteLine("Generating test data");

                var workplace   = new EfWorkplace(new TestDbContextProvider(context));
                var dataCreator = new TestDataGenerator();
                dataCreator.CreateRandomData(workplace);

                context.SaveChanges();

                Console.WriteLine("Test data generated");
            }
        }
示例#4
0
 public void EstablishContext()
 {
     _workplace = new EfWorkplace(TestContextCreator.Create());
 }