public void BeAbleToAddValidProduct(Product product, string expected) { //Arrange Products sut = new Products(); Product product1 = new Product { Name = "Lotion", IsSold = true }; Product product2 = new Product { Name = "BabyOil", IsSold = false }; //Act sut.AddNew(product1); sut.AddNew(product2); sut.AddNew(product); //Assert Assert.Contains(expected, sut.Items.Select(s => s.Name)); }
public void NotAllowNoOrNullProductName(Product product) { //Arrange Products sut = new Products(); Product product1 = new Product { Name = "Lotion", IsSold = true }; Product product2 = new Product { Name = "BabyOil", IsSold = false }; //Act sut.AddNew(product1); sut.AddNew(product2); Action act = () => sut.AddNew(product); //Assert Assert.Throws <NameRequiredException>(act); }
public void HideProductsIfSold(Product product, string expected) { //Arrange Products sut = new Products(); Product product1 = new Product { Name = "Lotion", IsSold = true }; Product product2 = new Product { Name = "BabyOil", IsSold = false }; //Act sut.AddNew(product1); sut.AddNew(product2); sut.AddNew(product); sut.Sold(product); //Assert Assert.DoesNotContain(expected, sut.Items.Select(s => s.Name)); }
public void NotBeAddingNullProduct() { //Arrange Products sut = new Products(); //Act and Action act = () => sut.AddNew(null); //Assert Assert.Throws <ArgumentNullException>(act); }
public void ReturnArgumentNullExceptionWhenProductIsNotSpecifiedOrNull() { //Arrange Products sut = new Products(); //Act Product product = null; //Assert Assert.Throws <ArgumentNullException>(() => sut.AddNew(product)); }
public void AddNewProductOnListIfProductIsAdded() { //Arrange Products sut = new Products(); //Act Product product = new Product() { Name = "ProductA" }; sut.AddNew(product); //Assert Assert.Contains(product, sut.Items); }
/// <summary> /// Demonstrates how to retrieve a single row of data. /// </summary> private void btnProductsAddDelete_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; Products prod = new Products(); prod.DefaultCommandType = chkStoredProcedures.Checked ? System.Data.CommandType.StoredProcedure : System.Data.CommandType.Text; // Call AddNew() to add a new row to the EasyObject. You must fill in all // required fields or an error will result when you call Save(). prod.AddNew(); // We're going to provide our own IDENTITY column for this record prod.IdentityInsert = true; // Note the use of the 's_' fields, which take strings as arguments. If this object // were being loaded from TextBox objects on a WinForm, you don't have to worry about // the datatype because this is handled for you in EasyObjects prod.s_ProductID = "78"; prod.s_ProductName = "EasyObjects"; prod.s_Discontinued = "True"; prod.s_QuantityPerUnit = "10"; prod.s_ReorderLevel = "100"; prod.s_UnitPrice = "49.95"; prod.s_UnitsInStock = "200"; // Save the changes prod.Save(); // Display the XML representation of the EasyObject string productDetails = prod.ToXml(); this.DisplayResults(this.btnProductsAddDelete.Text, prod.Query.LastQuery, productDetails); // Delete the new addition prod.MarkAsDeleted(); prod.Save(); Cursor = Cursors.Arrow; }