public void DeleteNotFound() { Mock <ILogger <OrganizationRepository> > loggerMoc = OrganizationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = OrganizationRepositoryMoc.GetContext(); var repository = new OrganizationRepository(loggerMoc.Object, context); Func <Task> delete = async() => { await repository.Delete(default(int)); }; delete.Should().NotThrow(); }
public async void Delete() { Mock <ILogger <OrganizationRepository> > loggerMoc = OrganizationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = OrganizationRepositoryMoc.GetContext(); var repository = new OrganizationRepository(loggerMoc.Object, context); Organization entity = new Organization(); context.Set <Organization>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); Organization modifiedRecord = await context.Set <Organization>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void DeleteFound() { Mock <ILogger <OrganizationRepository> > loggerMoc = OrganizationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = OrganizationRepositoryMoc.GetContext(); var repository = new OrganizationRepository(loggerMoc.Object, context); Organization entity = new Organization(); entity.SetProperties(default(int), "B"); context.Set <Organization>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); var records = await context.Set <Organization>().ToListAsync(); records.Count.Should().Be(1); }