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