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