Пример #1
0
    public void Insert_uint_to_Identity_column_using_value_converter()
    {
        using (var context = new BlogContextUIntToIdentityUsingValueConverter(
                   nameof(Insert_uint_to_Identity_column_using_value_converter)))
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            context.AddRange(
                new BlogWithUIntKey {
                Name = "One Unicorn"
            }, new BlogWithUIntKey {
                Name = "Two Unicorns"
            });

            context.SaveChanges();
        }

        using (var context = new BlogContextUIntToIdentityUsingValueConverter(
                   nameof(Insert_uint_to_Identity_column_using_value_converter)))
        {
            var blogs = context.UnsignedBlogs.OrderBy(e => e.Id).ToList();

            Assert.Equal((uint)1, blogs[0].Id);
            Assert.Equal((uint)2, blogs[1].Id);
        }
    }
        public void Insert_uint_to_Identity_column_using_value_converter()
        {
            using var testStore = SqlServerTestStore.CreateInitialized(DatabaseName);
            using (var context = new BlogContextUIntToIdentityUsingValueConverter(testStore.Name))
            {
                context.Database.EnsureCreatedResiliently();

                context.AddRange(
                    new BlogWithUIntKey {
                    Name = "One Unicorn"
                }, new BlogWithUIntKey {
                    Name = "Two Unicorns"
                });

                context.SaveChanges();
            }

            using (var context = new BlogContextUIntToIdentityUsingValueConverter(testStore.Name))
            {
                var blogs = context.UnsignedBlogs.OrderBy(e => e.Id).ToList();

                Assert.Equal((uint)1, blogs[0].Id);
                Assert.Equal((uint)2, blogs[1].Id);
            }
        }