public async void All() { Mock <ILogger <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); var records = await repository.All(); records.Should().NotBeEmpty(); records.Count.Should().Be(1); }
public async void Create() { Mock <ILogger <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); var entity = new Event(); await repository.Create(entity); var record = await context.Set <Event>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
public void DeleteNotFound() { Mock <ILogger <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); Func <Task> delete = async() => { await repository.Delete(default(int)); }; delete.Should().NotThrow(); }
public async void Get() { Mock <ILogger <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); Event entity = new Event(); context.Set <Event>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Create() { Mock <ILogger <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); var entity = new Event(); entity.SetProperties(default(int), "B", "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B"); await repository.Create(entity); var records = await context.Set <Event>().ToListAsync(); records.Count.Should().Be(2); }
public async void Delete() { Mock <ILogger <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); Event entity = new Event(); context.Set <Event>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); Event modifiedRecord = await context.Set <Event>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); Event entity = new Event(); context.Set <Event>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new Event()); var modifiedRecord = context.Set <Event>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); Event entity = new Event(); entity.SetProperties(default(int), "B", "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B"); context.Set <Event>().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 <EventRepository> > loggerMoc = EventRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = EventRepositoryMoc.GetContext(); var repository = new EventRepository(loggerMoc.Object, context); Event entity = new Event(); entity.SetProperties(default(int), "B", "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B"); context.Set <Event>().Add(entity); await context.SaveChangesAsync(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <Event>().ToListAsync(); records.Count.Should().Be(2); }