public async void Create() { Mock <ILogger <InvitationRepository> > loggerMoc = InvitationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = InvitationRepositoryMoc.GetContext(); var repository = new InvitationRepository(loggerMoc.Object, context); var entity = new Invitation(); await repository.Create(entity); var record = await context.Set <Invitation>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <InvitationRepository> > loggerMoc = InvitationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = InvitationRepositoryMoc.GetContext(); var repository = new InvitationRepository(loggerMoc.Object, context); Invitation entity = new Invitation(); context.Set <Invitation>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Delete() { Mock <ILogger <InvitationRepository> > loggerMoc = InvitationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = InvitationRepositoryMoc.GetContext(); var repository = new InvitationRepository(loggerMoc.Object, context); Invitation entity = new Invitation(); context.Set <Invitation>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); Invitation modifiedRecord = await context.Set <Invitation>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <InvitationRepository> > loggerMoc = InvitationRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = InvitationRepositoryMoc.GetContext(); var repository = new InvitationRepository(loggerMoc.Object, context); Invitation entity = new Invitation(); context.Set <Invitation>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new Invitation()); var modifiedRecord = context.Set <Invitation>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }