Пример #1
0
        public async void Create()
        {
            Mock <ILogger <PostLinkRepository> > loggerMoc = PostLinkRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostLinkRepositoryMoc.GetContext();
            var repository = new PostLinkRepository(loggerMoc.Object, context);

            var entity = new PostLink();

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, 1);
            await repository.Create(entity);

            var records = await context.Set <PostLink>().ToListAsync();

            records.Count.Should().Be(2);
        }
Пример #2
0
        public async void Get()
        {
            Mock <ILogger <PostLinkRepository> > loggerMoc = PostLinkRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostLinkRepositoryMoc.GetContext();
            var repository = new PostLinkRepository(loggerMoc.Object, context);

            PostLink entity = new PostLink();

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, 1);
            context.Set <PostLink>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
Пример #3
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <PostLinkRepository> > loggerMoc = PostLinkRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostLinkRepositoryMoc.GetContext();
            var      repository          = new PostLinkRepository(loggerMoc.Object, context);
            PostLink entity = new PostLink();

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, 1);
            context.Set <PostLink>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

            var records = await context.Set <PostLink>().ToListAsync();

            records.Count.Should().Be(2);
        }
Пример #4
0
        public virtual async Task Migrate()
        {
            var badgeItem1 = new Badge();

            badgeItem1.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1);
            this.Context.Badges.Add(badgeItem1);

            var commentItem1 = new Comment();

            commentItem1.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, "A", 1);
            this.Context.Comments.Add(commentItem1);

            var linkTypeItem1 = new LinkType();

            linkTypeItem1.SetProperties(1, "A");
            this.Context.LinkTypes.Add(linkTypeItem1);

            var postHistoryItem1 = new PostHistory();

            postHistoryItem1.SetProperties(1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, "A", "A", "A", 1);
            this.Context.PostHistories.Add(postHistoryItem1);

            var postHistoryTypeItem1 = new PostHistoryType();

            postHistoryTypeItem1.SetProperties(1, "A");
            this.Context.PostHistoryTypes.Add(postHistoryTypeItem1);

            var postLinkItem1 = new PostLink();

            postLinkItem1.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1);
            this.Context.PostLinks.Add(postLinkItem1);

            var postItem1 = new Post();

            postItem1.SetProperties(1, 1, 1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1, 1, 1, 1, 1, "A", "A", 1);
            this.Context.Posts.Add(postItem1);

            var postTypeItem1 = new PostType();

            postTypeItem1.SetProperties(1, "A");
            this.Context.PostTypes.Add(postTypeItem1);

            var tagItem1 = new Tag();

            tagItem1.SetProperties(1, 1, 1, "A", 1);
            this.Context.Tags.Add(tagItem1);

            var userItem1 = new User();

            userItem1.SetProperties(1, "A", 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1, 1, 1, "A");
            this.Context.Users.Add(userItem1);

            var voteItem1 = new Vote();

            voteItem1.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1);
            this.Context.Votes.Add(voteItem1);

            var voteTypeItem1 = new VoteType();

            voteTypeItem1.SetProperties(1, "A");
            this.Context.VoteTypes.Add(voteTypeItem1);

            await this.Context.SaveChangesAsync();
        }