public async void All() { Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = AirTransportRepositoryMoc.GetContext(); var repository = new AirTransportRepository(loggerMoc.Object, context); var records = await repository.All(); records.Should().NotBeEmpty(); records.Count.Should().Be(1); }
public async void Create() { Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = AirTransportRepositoryMoc.GetContext(); var repository = new AirTransportRepository(loggerMoc.Object, context); var entity = new AirTransport(); await repository.Create(entity); var record = await context.Set <AirTransport>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
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 Get() { 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(); var record = await repository.Get(entity.AirlineId); record.Should().NotBeNull(); }
public async void Create() { Mock <ILogger <AirTransportRepository> > loggerMoc = AirTransportRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = AirTransportRepositoryMoc.GetContext(); var repository = new AirTransportRepository(loggerMoc.Object, context); var 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")); await repository.Create(entity); var records = await context.Set <AirTransport>().ToListAsync(); records.Count.Should().Be(2); }
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 Update_Entity_Is_Not_Tracked() { 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.Update(new AirTransport()); var modifiedRecord = context.Set <AirTransport>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Get() { 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(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Update_Entity_Is_Not_Tracked() { 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(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <AirTransport>().ToListAsync(); records.Count.Should().Be(2); }