public void AddCallsAddFromRepository() { var testItem = ProductObjectMother.CreateAvailableProduct(1); ProductService.Add(testItem); ProductRepositoryMock.Verify(x => x.Add(testItem), Times.Once()); }
public void IsAvailableReturnsFalseWithQuantityZero() { var product = ProductObjectMother.CreateUnavailableProduct(1); var res = product.IsAvailable(); Assert.IsFalse(res); }
public void IsAvailableReturnsTrueWithPositiveQuantity() { var product = ProductObjectMother.CreateAvailableProduct(1); var res = product.IsAvailable(); Assert.IsTrue(res); }
public void UpdateCallsUpdateFromRepository() { var product = ProductObjectMother.CreateProductWithNoId(); ProductService.Add(product); product.Name = "New name"; ProductService.Update(product); ProductRepositoryMock.Verify(x => x.Update(product)); }
public void CheckAddProperty() { ShopService ss = new ShopService(); var product = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand(); var property = ProductObjectMother.CreatePropertyColorWithValueBlue(); ss.AddProperty(product, property); Assert.AreEqual(product.Properties.Contains(property), true); }
public void CheckSetBrand() { ShopService ss = new ShopService(); var product = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand(); var brand = ProductObjectMother.CreateBrandWithNameHoyt(); ss.SetBrand(product, brand); Assert.AreEqual(product.Brand, brand); }
public void CheckCreateCategoryMethodResult() { Category category = ProductObjectMother.CreateCategory(); var transaction = _session.BeginTransaction(); ps.CreateCategory(category); transaction.Commit(); List <Category> categories = ps.GetAllCategory(); Assert.AreEqual(1, categories.Count); }
public void CheckCreateArtistMethodResult() { Artist artist = ProductObjectMother.CreateArtist(); var transaction = _session.BeginTransaction(); ps.CreateArtist(artist); transaction.Commit(); List <Artist> artists = ps.GetAllArtists(); Assert.AreEqual(1, artists.Count); }
public void CheckGetArtistMethodResult() { Artist artist = ProductObjectMother.CreateArtist(); var transaction = _session.BeginTransaction(); ps.CreateArtist(artist); transaction.Commit(); Artist result = ps.GetArtist(artist.Id); Assert.AreEqual(artist.Id, result.Id); }
public void CheckPropertyToProduct() { // Arrange var product = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand(); var property = ProductObjectMother.CreatePropertyColorWithValueBlue(1); product.properties.Add(property); // Assert Assert.IsTrue(product.properties.Count == 1); }
public void CheckSetBrandToProduct() { // Arrange var product = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand(); var brand = ProductObjectMother.CreateBrandWithNameHoyt(1); product.Brand = brand; // Assert Assert.IsTrue(product.Brand.Name == "Hoyt"); }
public void CheckInsertMethodCalled() { // Arrange Mock <IProductRepository> repositoryMock = new Mock <IProductRepository>(); IProductService service = new ProductService(repositoryMock.Object); var product = ProductObjectMother.CreateProduct(); // Act service.Insert(product); // Assert repositoryMock.Verify(k => k.Insert(product), Times.Once()); }
public void CheckAddToOrder() { ShopService ss = new ShopService(); Product product = ProductObjectMother.CreateProductWithNoPropertiesAndNoBrand(); Order order = OrderObjectMother.CreateOrderWithNoItems(); int quantitity = 2; var orderItems = ss.AddToOrder(product, order, quantitity); Assert.AreEqual(orderItems.Product, product); Assert.AreEqual(orderItems.Quantitity, quantitity); Assert.AreEqual(order.OrderItems.Contains(orderItems), true); }
public Album CreateArtistCategoryAlbum() { var transaction = _session.BeginTransaction(); Artist artist = ps.CreateArtist(ProductObjectMother.CreateArtist()); Category category = ps.CreateCategory(ProductObjectMother.CreateCategory()); Album album = ProductObjectMother.CreateAlbum(); album.Artist = artist; album.Category = category; album = ps.CreateAlbum(album); transaction.Commit(); return(album); }