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