本文整理汇总了C#中Acme.Biz.Product类的典型用法代码示例。如果您正苦于以下问题:C# Product类的具体用法?C# Product怎么用?C# Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Product类属于Acme.Biz命名空间,在下文中一共展示了Product类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlaceOrder
/// <summary>
/// Sends a product order to the vendor.
/// </summary>
/// <param name="product">Product to order.</param>
/// <param name="quantity">Quantity of the product to order.</param>
/// <returns></returns>
public OperationResult PlaceOrder(Product product, int quantity)
{
//// Guard clauses make sure passed in values are within constraints.
//if (product == null) throw new ArgumentNullException(nameof(product));
//if (quantity <= 0) throw new ArgumentOutOfRangeException(nameof(product));
//var success = false;
//var orderText = "Order from ACME, Inc" + "\n" +
// "Product: " + product.ProductCode + "\n" +
// "Quantity: " + quantity;
//var emailService = new EmailService();
//var confirmation = emailService.SendMessage("New Order", orderText, Email);
//if (confirmation.StartsWith("Message sent: "))
//{
// success = true;
//}
//var operationResult = new OperationResult(success, orderText);
//return operationResult;
//// Example of method chaining
return PlaceOrder(product, quantity, null, null);
}
示例2: PlaceOrder
/// <summary>
/// Sends a product order to the vendor.
/// </summary>
/// <param name="product">Product to order.</param>
/// <param name="quantity">Quantity of the product to order.</param>
/// <param name="includeAddress">True to include the shipping address in the order.</param>
/// <param name="sendCopy">True to send a copy of the email to the current user.</param>
/// <returns>Success flag and order text</returns>
public OperationResult PlaceOrder(Product product, int quantity,
IncludeAddress includeAddress,
SendCopy sendCopy)
{
var orderText = "Test";
if (includeAddress == IncludeAddress.Yes) orderText += " With Address";
if (sendCopy == SendCopy.Yes) orderText += " With Copy";
var operationResult = new OperationResult(true, orderText);
return operationResult;
}
示例3: MinimumPriceTest_Default
public void MinimumPriceTest_Default()
{
//Arrage
var currentProduct = new Product();
var expectedMessage = 0.96m;
//Act
var actual = currentProduct.MinimumPrice;
//Assert
Assert.AreEqual(expectedMessage, actual);
}
示例4: MinimumPriceTest_Bulk
public void MinimumPriceTest_Bulk()
{
//Arrange
var currentProduct = new Product(1, "Bulk Tools", "");
var expected = 9.99m;
//Act
var actual = currentProduct.MinimumPrice;
//Assert
Assert.AreEqual(expected, actual);
}
示例5: SayHello_ParameterizedConstructor_Test
public void SayHello_ParameterizedConstructor_Test()
{
//Arrange
var currentProduct = new Product("Honda", 2346, "Nice car from Japan");
var expected = "Hello Honda (2346): Nice car from Japan" + " Available on: ";
//Act
var actual = currentProduct.SayHello();
//Assert
Assert.AreEqual(expected, actual);
}
示例6: SayHello_ParameterizedConstructor
public void SayHello_ParameterizedConstructor()
{
//Arrange
var currentProduct = new Product(1, "Saw",
"15-inch steel blade hand saw");
var expected = "Hello Saw (1): 15-inch steel blade hand saw";
//Act
var actual = currentProduct.SayHello();
//Assert
Assert.AreEqual(expected, actual);
}
示例7: ProductName_Format
public void ProductName_Format()
{
//Arrange
var currentProduct = new Product();
currentProduct.ProductName = " Steel Hammer ";
var expected = "Steel Hammer";
//Act
var actual = currentProduct.ProductName;
//Assert
Assert.AreEqual(expected, actual);
}
示例8: CalculateSuggestedPriceTest
public void CalculateSuggestedPriceTest()
{
// Arrange
var currentProduct = new Product(1, "Saw", "");
currentProduct.Cost = 50m;
var expected = 55m;
// Act
var actual = currentProduct.CalculateSuggestedPrice(10m);
// Assert
Assert.AreEqual(expected, actual);
}
示例9: CalculateSuggestedPriceTest
public void CalculateSuggestedPriceTest()
{
// Arrange
var currentProduct = new Product(1, "Saw", "");
currentProduct.Cost = 50m;
var expected = new OperationResult<decimal>(55m, "");
// Act
var actual = currentProduct.CalculateSuggestedPrice(10m);
// Assert
Assert.AreEqual(expected.Result, actual.Result);
Assert.AreEqual(expected.Message, actual.Message);
}
示例10: SayHello_ParamterizedConstructor
public void SayHello_ParamterizedConstructor()
{
//Arrange
var currentProduct = new Product(1, "Hammer", "A sturdy tool");
var expected = "Hello Hammer (1): A sturdy tool" +
" Available on: ";
//Act
var actual = currentProduct.SayHello();
//Assert
Assert.AreEqual(expected, actual);
}
示例11: SayHelloTest
public void SayHelloTest()
{
//Arrange
var currentProduct = new Product();
currentProduct.ProductName = "Saw";
currentProduct.ProductId = 1;
currentProduct.Description = "15-inch steel blade hand saw";
var expected = "Hello Saw (1): 15-inch steel blade hand saw";
//Act
var actual = currentProduct.SayHello();
//Assert
Assert.AreEqual(expected, actual);
}
示例12: PlaceOrderTest
public void PlaceOrderTest()
{
// Arrange
var vender = new Vendor();
var product = new Product(1, "Hammer", "");
var expected = new OperationResult(true,
"Order from ACME, Inc\nProduct: Tools-1\nQuantity: 1");
// Act
var actual = vender.PlaceOrder(product, 1);
// Assert
Assert.AreEqual(expected.Success, actual.Success);
Assert.AreEqual(expected.Message, actual.Message);
}
示例13: SayHelloTest
public void SayHelloTest()
{
//Arrange
var currentProduct = new Product();
currentProduct.ProductName = "Honda";
currentProduct.ProductId = 2346;
currentProduct.Description = "Nice car from Japan";
currentProduct.ProductVendor.CompanyName = "Honda Ltd.";
var expected = "Hello Honda (2346): Nice car from Japan" + " Available on: ";
//Act
var actual = currentProduct.SayHello();
//Assert
Assert.AreEqual(expected, actual);
}
示例14: SayHello_ParameterizedConstructorTest
public void SayHello_ParameterizedConstructorTest()
{
//Arrage
var currentProduct = new Product(1,"Saw", "Steel Blade hand saw");
//currentProduct.ProductId = 1;
//currentProduct.ProductName = "Saw";
//currentProduct.Description = "Steel Blade hand saw";
var expectedMessage = "Hello Saw (1) Steel Blade hand saw";
//Act
Console.WriteLine("Current Product" + currentProduct.ProductName);
var actual = currentProduct.SayHello();
//Assert
Assert.AreEqual(expectedMessage, actual);
}
示例15: SayHelloParmTest
public void SayHelloParmTest()
{
//arrange
var currentProduct = new Product(1, "Saw", "15-inch steel blade hand saw");
var expected = "Hello Saw (1) 15-inch steel blade hand saw" +
" Available on: ";
//act
var actual = currentProduct.SayHello();
//assert
Assert.AreEqual(expected, actual);
}