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