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