public void GetCompanyProductNotFound() { UoW.Setup(m => m.CompanyProducts.GetAll()).Returns(new List <CompanyProduct> { }.AsQueryable()); // Act var result = Subject.GetCompanyProduct(TestData.ProductSkuCompanyCodeA, TestData.CompanyCodeA); // Assert Assert.Null(result); }
public void GetSupplierNotFound() { UoW.Setup(m => m.Suppliers.GetAll()).Returns(new List <Supplier> { }.AsQueryable()); // Act var result = Subject.GetSupplier(TestData.ExistingSupplierCode, TestData.CompanyCodeA); // Assert Assert.Null(result); }
public void ValidateCompanyProductDoesNotExist() { UoW.Setup(m => m.CompanyProducts.GetAll()).Returns(new List <CompanyProduct> { }.AsQueryable()); // Act var result = Subject.ValidateCompanyProductExist(TestData.ProductSkuCompanyCodeA, TestData.CompanyCodeA); // Assert Assert.Contains(typeof(ProductSkuNotFoundError), result.Where(m => m.Field == "ProductSku").Select(e => e.GetType()).ToList()); }
public void ValidateSupplierDoesNotExist() { UoW.Setup(m => m.Suppliers.GetAll()).Returns(new List <Supplier> { }.AsQueryable()); // Act var result = Subject.ValidateSupplierExist(TestData.ExistingSupplierCode, TestData.CompanyCodeA); // Assert Assert.Contains(typeof(SupplierCodeNotFoundError), result.Where(m => m.Field == "SupplierCode").Select(e => e.GetType()).ToList()); }
public async void GivenModel_ManagerWillUpdateEntityRecord() { // Arrange var manager = new GenericManager <Word>(UoWFactoryMock.Object); UoW.Setup(m => m.CreateRepository <IGenericRepository <Word> >().Update(It.IsAny <Word>())).Verifiable(); // Act await manager.UpdateAsync(word).ConfigureAwait(false); // Assert UoW.Verify(m => m.CreateRepository <IGenericRepository <Word> >().Update(It.Is <Word>(it => it.Id == word.Id))); }
public void ExceptionErrorIsReturned() { // Assemble var request = TestData.GetCreateCompanyProductRequest(); UoW.Setup(m => m.Save()) .Throws <Exception>(); // Act var result = Subject.CreateCompanyProduct(request); // Assert Assert.Contains(typeof(ExceptionError), result.Errors.Select(e => e.GetType()).ToList()); }
public async void GivenModelId_ManagerFindsEntity() { // Arrange var manager = new GenericManager <Word>(UoWFactoryMock.Object); UoW.Setup(m => m.CreateRepository <IGenericRepository <Word> >().FindByIdAsync(It.IsAny <int>())) .Returns(Task.FromResult(word)).Verifiable(); // Act await manager.FindByIdAsync(betId).ConfigureAwait(false); // Assert UoW.Verify(m => m.CreateRepository <IGenericRepository <Word> >().FindByIdAsync(It.Is <int>(it => it == word.Id))); }
public async void GivenNothing_ManagerReturnsAllRecords() { // Arrange var manager = new GenericManager <Word>(UoWFactoryMock.Object); UoW.Setup(m => m.CreateRepository <IGenericRepository <Word> >().AllAsync()) .Returns(Task.FromResult(new List <Word> { word })); // Act var records = await manager.GetAllAsync().ConfigureAwait(false); // Assert Assert.Single(records); Assert.Equal(records[0].Id, betId); }