public void RemoveProductWhenObjectDoesnotExistsIn() { //Arrange var targetGood = new Good() { Price = 12.2m, Supplier = new Supplier() { Name = "Maxim" } }; var map = new Dictionary <string, IProduct>(new List <KeyValuePair <string, IProduct> > { new KeyValuePair <string, IProduct>("cart_list_1", new Good()), }); var expected = map; var context = FakeHttpContext.NewFakeHttpContext(); context.SetupProperty(e => e.Session, FakeHttpContext.FakeSession(map).Object); var cart = new Cart(context.Object); //Actual cart.Remove(targetGood); //Assert NAssert.AreEqual(expected, map); }
public void AddProduct_WhenSessionIsNotClear_ResultAdd2ProductsToCart() { //Arrange var map = new Dictionary <string, IProduct>(new List <KeyValuePair <string, IProduct> > { new KeyValuePair <string, IProduct>("cart_list_0", new Good()), new KeyValuePair <string, IProduct>("cart_list_1", new Good()), new KeyValuePair <string, IProduct>("cart_list_2", new Good()), }); ICollection <IProduct> collection = new List <IProduct>((IEnumerable <IProduct>) new[] { new Good(), new Good() }); var context = FakeHttpContext.NewFakeHttpContext(); context.SetupProperty(e => e.Session, FakeHttpContext.FakeSession(map).Object); var cart = new Cart(context.Object); //Actual cart.AddProduct(collection.ToArray()); //Assert Assert.Equal(map.Count, cart.AmountProducts()); }
public void GetAllProductsWhenOnesAreNotClear() { //Arrange var expectedList = new[] { new Good(), new Good() }; var listObjects = new List <KeyValuePair <string, IProduct> > { new KeyValuePair <string, IProduct>("cart_list_1", new Good()), new KeyValuePair <string, IProduct>("cart_list_2", new Good()) }; var map = new Dictionary <string, IProduct>(listObjects); var context = FakeHttpContext.NewFakeHttpContext(); context.SetupProperty(c => c.Session, FakeHttpContext.FakeSession(map).Object); var cart = new Cart(context.Object); //Actual var actual = cart.All(); //Assert Assert.Equal(expectedList, actual); }
public void AddProductSingle_WhenDataIsNULL_ExpectedExeption() { //Arrange var map = new Dictionary <string, IProduct>(); var context = FakeHttpContext.NewFakeHttpContext(); context.SetupProperty(e => e.Session, FakeHttpContext.FakeSession(map).Object); var cart = new Cart(context.Object); //Assert Assert.Throws <ArgumentNullException>(() => cart.AddProduct((IProduct)null)); }
public void RemoveWhenProductIsNull() { //Arrange var map = new Dictionary <string, IProduct>(new List <KeyValuePair <string, IProduct> > { }); var context = FakeHttpContext.NewFakeHttpContext(); context.SetupProperty(e => e.Session, FakeHttpContext.FakeSession(map).Object); var cart = new Cart(context.Object); //Actual cart.Remove(null); //Assert NAssert.AreEqual(map, map); }
public void GetAllProductsWhenOnesIsEmpty() { //Arrange var expected = new List <IProduct>(); var map = new Dictionary <string, IProduct>(); var context = FakeHttpContext.NewFakeHttpContext(); context.SetupProperty(c => c.Session, FakeHttpContext.FakeSession(map).Object); var cart = new Cart(context.Object); //Actual var actual = cart.All(); //Assert Assert.Equal(expected, actual); }