public void ThrowNullArgumentException_WhenProductNameIsNull() { //Arrange var fakeContext = new Mock <IOnlineStoreContext>(); var fakemapper = new Mock <IMapper>(); var fakeCategoryService = new Mock <ICategoryService>(); var service = new Logic.Services.ProductService(fakeContext.Object, fakemapper.Object, fakeCategoryService.Object); //Act && Assert Assert.ThrowsException <ArgumentNullException>(() => service.ProductExistsByName(null)); }
public void ReturnFalse_WhenProductDoesNotExist() { //Arrange Mapper.Reset(); AutomapperConfiguration.Initialize(); var mockContext = new Mock <IOnlineStoreContext>(); var productsMock = new List <Product> { new Product { Name = "Pesho" } }.GetQueryableMockDbSet(); var fakemapper = new Mock <IMapper>(); var fakeCategoryService = new Mock <ICategoryService>(); mockContext.Setup(s => s.Products).Returns(productsMock.Object); var service = new Logic.Services.ProductService(mockContext.Object, fakemapper.Object, fakeCategoryService.Object); //Act var searchResult = service.ProductExistsByName("Pesho go nqma"); //Assert Assert.IsFalse(searchResult); }