public async void Create() { Mock <ILogger <PostTypeRepository> > loggerMoc = PostTypeRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostTypeRepositoryMoc.GetContext(); var repository = new PostTypeRepository(loggerMoc.Object, context); var entity = new PostType(); entity.SetProperties(default(int), "B"); await repository.Create(entity); var records = await context.Set <PostType>().ToListAsync(); records.Count.Should().Be(2); }
public async void Get() { Mock <ILogger <PostTypeRepository> > loggerMoc = PostTypeRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostTypeRepositoryMoc.GetContext(); var repository = new PostTypeRepository(loggerMoc.Object, context); PostType entity = new PostType(); entity.SetProperties(default(int), "B"); context.Set <PostType>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void DeleteFound() { Mock <ILogger <PostTypeRepository> > loggerMoc = PostTypeRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostTypeRepositoryMoc.GetContext(); var repository = new PostTypeRepository(loggerMoc.Object, context); PostType entity = new PostType(); entity.SetProperties(default(int), "B"); context.Set <PostType>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); var records = await context.Set <PostType>().ToListAsync(); records.Count.Should().Be(1); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <PostTypeRepository> > loggerMoc = PostTypeRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostTypeRepositoryMoc.GetContext(); var repository = new PostTypeRepository(loggerMoc.Object, context); PostType entity = new PostType(); entity.SetProperties(default(int), "B"); context.Set <PostType>().Add(entity); await context.SaveChangesAsync(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <PostType>().ToListAsync(); records.Count.Should().Be(2); }
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(); }