Example #1
0
        public void SaveChangesDoesntFail()
        {
            var sut = ContextGenerator.Generate <ITestContext>();

            var res = sut.SaveChanges();

            Assert.AreEqual(0, res);
        }
Example #2
0
        public void TestPropertiesCreated()
        {
            var sut = ContextGenerator.Generate <ITestContext>();

            Assert.IsInstanceOf <InMemoryDbSet <Entity> >(sut.Entity1s);
            Assert.IsInstanceOf <InMemoryDbSet <Entity> >(sut.Entity2s);
            Assert.IsFalse(sut.Entity1s == sut.Entity2s);
            Assert.IsTrue(sut.Entity1s == sut.Entity1s);
        }
Example #3
0
        static async Task Main(string[] args)
        {
            //TestProtobufSerialization();

            var options = new DbContextOptionsBuilder <TestDBContext>()
                          .UseInMemoryDatabase("Test")
                          .Options;

            var writer = new DefaultFileGGDBFDataWriter(new DefaultGGDBFProtobufNetSerializer());

            await using TestDBContext context = new(options);
            await context.Database.EnsureCreatedAsync();

            await InitializeDatabase(context);

            ContextGenerator <TestContext> generator = new ContextGenerator <TestContext>(new EntityFrameworkGGDBFDataSource(context), writer);

            await generator.Generate();

            //Reload the data
            await TestContext.Initialize(new FileGGDBFDataSource(new DefaultGGDBFProtobufNetSerializer()));

            if (TestContext.Instance.TestDatas.Values.Count() != 3)
            {
                throw new InvalidOperationException($"{nameof(TestModelType)} does not have expected entry count.");
            }

            if (TestContext.Instance.Test3DatasWithFK.Values.First().ModelId == null)
            {
                throw new InvalidOperationException($"{nameof(TestModelType3)} nav property key null.");
            }

            if (TestContext.Instance.Test3DatasWithFK.Values.First().Model == null)
            {
                throw new InvalidOperationException($"{nameof(TestModelType3)} nav property is null.");
            }

            if (TestContext.Instance.Test4Datas.Values.First().ModelCollection.Count() != 3)
            {
                throw new InvalidOperationException($"{nameof(TestModelType4)} collection nav property is invalid.");
            }
        }