Exemple #1
0
        public void CanMapEntityTypeToTypeNameTable()
        {
            var registry = new AggregateTableEntityMapper(new TypeNameTableEntityMapper());

            Assert.Equal("Musician", registry.GetTable(typeof(Musician)));
            Assert.Equal("Musician", registry.GetTable <Musician>());

            var musician = new Musician("John Doe", "Anonymous", "*****@*****.**");

            Assert.Equal("Musician", registry.GetTable(musician));
        }
        public async Task SaveChanges_Should_ReturnNumberOfProcessedRecords()
        {
            var registry = new AggregateTableEntityMapper(new RegistryTableEntityMapper(), new AttributeTableEntityMapper(), new TypeNameTableEntityMapper());
            await context.DeleteTableAsync("Musician");

            var musician1 = new Musician("John Doe", "Anonymous", "*****@*****.**");
            var musician2 = new Musician("Bill Coal", "Anonymous", "*****@*****.**");

            await context.DeleteTableAsync(registry.GetTable <Musician>());

            context.RegisterNew(musician1);
            context.RegisterNew(musician2);

            var records = await context.SaveChangesAsync();

            Assert.Equal(2, records);

            await context.DeleteTableAsync(registry.GetTable <Musician>());
        }