public void Invalid_product_type_name(string name) { var sut = ProductType.Create(Guid.NewGuid(), "type"); Action action = () => sut.UpdateProductTypeName(name); Assert.Throws <ArgumentException>(action.Invoke); }
public void Valid_product_type_name(string name) { var sut = ProductType.Create(Guid.NewGuid(), "type"); sut.UpdateProductTypeName(name); Assert.Equal(name, sut.Name); }
public void Brand_created() { var productTypeId = new ProductTypeId(SequentialGuid.NewSequentialGuid()); var sut = ProductType.Create(productTypeId, "New ProductType"); Assert.NotNull(sut); Assert.Contains("New ProductType", sut.Name); }
public void Product_type_name_cannot_be_null() { var sut = ProductType.Create(Guid.NewGuid(), "type"); Action action = () => sut.UpdateProductTypeName(null); Assert.Throws <ArgumentNullException>(action.Invoke); }
public void Invalid_size_update() { var sut = Product.Create(new ProductId(SequentialGuid.NewSequentialGuid()), "Duff", Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "Duff"), ProductType.Create(Guid.NewGuid(), "product type"), Size.Create(Guid.NewGuid(), "your size")); Assert.Throws <ArgumentNullException>(() => sut.UpdateSize(null)); }
public void Product_name_cannot_be_null() { var sut = Product.Create(new ProductId(SequentialGuid.NewSequentialGuid()), "Duff", Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "Duff"), ProductType.Create(Guid.NewGuid(), "product type"), Size.Create(Guid.NewGuid(), "your size")); Action action = () => sut.UpdateProductName(null); Assert.Throws <ArgumentNullException>(action.Invoke); }
public void Invalid_product_name(string name) { var sut = Product.Create(new ProductId(SequentialGuid.NewSequentialGuid()), "Duff", Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "Duff"), ProductType.Create(Guid.NewGuid(), "product type"), Size.Create(Guid.NewGuid(), "your size")); Action action = () => sut.UpdateProductName(name); Assert.Throws <ArgumentException>(action.Invoke); }
public void Valid_product_name(string name) { var sut = Product.Create(new ProductId(SequentialGuid.NewSequentialGuid()), "Duff", Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "Duff"), ProductType.Create(Guid.NewGuid(), "product type"), Size.Create(Guid.NewGuid(), "your size")); sut.UpdateProductName(name); Assert.Equal(name, sut.Name); }
public void Product_created() { var productId = new ProductId(SequentialGuid.NewSequentialGuid()); var brandId = Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "Duff"); var productType = ProductType.Create(Guid.NewGuid(), "product type"); var size = Size.Create(Guid.NewGuid(), "your size"); var sut = Product.Create(productId, "Duff", brandId, productType, size); Assert.NotNull(sut); Assert.Contains("Duff", sut.Name); }
public void Valid_size_update() { var sut = Product.Create(new ProductId(SequentialGuid.NewSequentialGuid()), "Duff", Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "Duff"), ProductType.Create(Guid.NewGuid(), "product type"), Size.Create(Guid.NewGuid(), "your size")); var newSize = Size.Create(new SizeId(SequentialGuid.NewSequentialGuid()), "0.33"); sut.UpdateSize(newSize); Assert.Equal("0.33", sut.Size.Amount); }
public void Valid_brand_update() { var sut = Product.Create(new ProductId(SequentialGuid.NewSequentialGuid()), "Duff", Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "Duff"), ProductType.Create(Guid.NewGuid(), "product type"), Size.Create(Guid.NewGuid(), "your size")); var newBrand = Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "DuffZ"); sut.UpdateBrand(newBrand); Assert.Equal("DuffZ", sut.Brand.Name); }
public void Valid_product_type_update() { var sut = Product.Create(new ProductId(SequentialGuid.NewSequentialGuid()), "Duff", Brand.Create(new BrandId(SequentialGuid.NewSequentialGuid()), "Duff"), ProductType.Create(Guid.NewGuid(), "product type"), Size.Create(Guid.NewGuid(), "your size")); var newProductType = ProductType.Create(new ProductTypeId(SequentialGuid.NewSequentialGuid()), "Duff IPA"); sut.UpdateProductType(newProductType); Assert.Equal("Duff IPA", sut.ProductType.Name); }
public void Has_product() { var price = new Price(1.00m); var brand = Brand.Create(Guid.NewGuid(), "test"); var productType = ProductType.Create(Guid.NewGuid(), "product type"); var size = Size.Create(Guid.NewGuid(), "your size"); var prodId = new ProductId(SequentialGuid.NewSequentialGuid()); var product = Product.Create(prodId, "newProd", brand, productType, size); var sut = LineItemBuilder.LineItem(price).WithProduct(product).Build(); Assert.Contains("newProd", sut.Product.Name); }
public async Task Invalid_Id_Returns_Null() { var id = Guid.NewGuid(); var productType = ProductType.Create(id, "type"); var mockProductTypeService = new Mock <IProductTypeService>(); mockProductTypeService.Setup(s => s.GetProductTypeAsync(Guid.NewGuid())) .Returns(() => Task.FromResult(productType)); var productTypeController = new ProductTypeController(mockProductTypeService.Object); var result = await productTypeController.GetProductType(id); Assert.Null(result); }
public void Has_notes() { var brand = Brand.Create(Guid.NewGuid(), "brand"); var productType = ProductType.Create(Guid.NewGuid(), "product type"); var size = Size.Create(Guid.NewGuid(), "your size"); var product = Product.Create(Guid.NewGuid(), "product", brand, productType, size); var price = new Price(1.00m); var sut = LineItemBuilder.LineItem(price) .WithNotes("No kun sai niin halvalla.") .WithProduct(product) .Build(); Assert.Contains("halvalla", sut.Notes); }
public async Task Valid_Id_Returns_Product() { var id = Guid.NewGuid(); var brand = Brand.Create(Guid.NewGuid(), "brand"); var productType = ProductType.Create(Guid.NewGuid(), "product type"); var size = Size.Create(Guid.NewGuid(), "your size"); var product = Product.Create(id, "product", brand, productType, size); var mockProductService = new Mock <IProductService>(); mockProductService.Setup(s => s.GetProductAsync(id)) .Returns(() => Task.FromResult(product)); var productController = new ProductController(mockProductService.Object); var result = await productController.GetProduct(id); mockProductService.Verify(mock => mock.GetProductAsync(id), Times.Once()); Assert.NotNull(result); }
public void Total_sum_of_line_items() { var sut = CreatePurchaseTransaction(); var brand = Brand.Create(Guid.NewGuid(), "brand"); var productType = ProductType.Create(Guid.NewGuid(), "product type"); var size = Size.Create(Guid.NewGuid(), "your size"); var product = Product.Create(Guid.NewGuid(), "prod", brand, productType, size); for (int i = 1; i < 6; i++) { var lineItem = LineItemBuilder.LineItem(new Price(1.0m * i)) .WithProduct(product) .Build(); sut.UpdateLineItem(lineItem); } Assert.Contains("15.0", sut.TotalPrice); }
public async Task Add_lineItem_with_notes() { var brand = Brand.Create(Guid.NewGuid(), "brand"); var productType = ProductType.Create(Guid.NewGuid(), "product type"); var size = Size.Create(Guid.NewGuid(), "your size"); var product = Product.Create(Guid.NewGuid(), "product", brand, productType, size); var lineItem = LineItemBuilder.LineItem(new Price(1.00m)) .WithNotes("My Notes!") .WithProduct(product) .Build(); PurchaseTransactionId transactionId = await CreateValidPurchaseTransaction(1m, lineItem); var repository = new PurchaseTransactionRepository(fixture.context); var sut = await repository.GetAsync(transactionId); Assert.True(await repository.ExistsAsync(transactionId)); Assert.Equal("My Notes!", sut.LineItems.FirstOrDefault()?.Notes); }
public void Valid_lineItem(decimal amount, Booking booking, string currencyCode, string currencySymbol, CurrencySymbolPosition currencySymbolPosition) { var brand = Brand.Create(Guid.NewGuid(), "brand"); var productType = ProductType.Create(Guid.NewGuid(), "product type"); var size = Size.Create(Guid.NewGuid(), "your size"); var product = Product.Create(Guid.NewGuid(), "product", brand, productType, size); var price = new Price(amount, booking, currencyCode, currencySymbol, currencySymbolPosition); var sut = LineItemBuilder.LineItem(price).WithProduct(product).Build(); Assert.IsType <LineItem>(sut); Assert.Equal(amount, sut.Price.Amount); Assert.Equal(booking, sut.Price.Booking); Assert.Equal(currencyCode, sut.Price.Currency.CurrencyCode); Assert.Equal(currencySymbol, sut.Price.Currency.CurrencySymbol); Assert.Equal(currencySymbolPosition, sut.Price.Currency.PositionRelativeToPrice); }
public void Valid_line_item_update() { var sut = CreatePurchaseTransaction(); Assert.NotNull(sut.LineItems); Assert.True(sut.LineItems.Count == 0); var brand = Brand.Create(Guid.NewGuid(), "brand"); var productType = ProductType.Create(Guid.NewGuid(), "product type"); var size = Size.Create(Guid.NewGuid(), "your size"); var product = Product.Create(Guid.NewGuid(), "prod", brand, productType, size); var newLineItem = LineItemBuilder .LineItem(new Price(1.1m)) .WithProduct(product) .Build(); sut.UpdateLineItem(newLineItem); Assert.True(sut.LineItems.Count == 1); }
public void ProductType_not_created(ProductTypeId id, string name) { Action sut = () => ProductType.Create(id, name); Assert.Throws <ArgumentNullException>(sut.Invoke); }