public void DeleteNotFound() { Mock <ILogger <FollowerRepository> > loggerMoc = FollowerRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = FollowerRepositoryMoc.GetContext(); var repository = new FollowerRepository(loggerMoc.Object, context); Func <Task> delete = async() => { await repository.Delete(default(int)); }; delete.Should().NotThrow(); }
public async void Delete() { Mock <ILogger <FollowerRepository> > loggerMoc = FollowerRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = FollowerRepositoryMoc.GetContext(); var repository = new FollowerRepository(loggerMoc.Object, context); Follower entity = new Follower(); context.Set <Follower>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); Follower modifiedRecord = await context.Set <Follower>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void DeleteFound() { Mock <ILogger <FollowerRepository> > loggerMoc = FollowerRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = FollowerRepositoryMoc.GetContext(); var repository = new FollowerRepository(loggerMoc.Object, context); Follower entity = new Follower(); entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B"); context.Set <Follower>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); var records = await context.Set <Follower>().ToListAsync(); records.Count.Should().Be(1); }