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() }); }
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); } }
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"); } }
public void EstablishContext() { _workplace = new EfWorkplace(TestContextCreator.Create()); }