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