public void TestStore() { Store testStore = new Store(new List <User> { userAdmin, commonUser }, items); testStore.AddBonus(bonuses[0]); testStore.AddBonus(bonuses[1]); testStore.AddItemIntoUserCart(commonUser, items[0].Copy(1)); testStore.AddItemIntoUserCart(commonUser, items[1].Copy(1)); testStore.AddItemIntoUserCart(commonUser, items[2].Copy(1)); //test Buy when user have no enought money Assert.Throws <Store.NotEnoughMoneyException>(() => testStore.BuyCart(commonUser.GetUserId())); testStore.ChangeItemCountInUserCart(commonUser, commonUser.GetUserCart().GetItems()[1], 100); //test buy when we have not enough items in the store Assert.Throws <Store.NotEnoughItemsException>(() => testStore.BuyCart(commonUser.GetUserId())); testStore.ChangeItemCountInUserCart(commonUser, commonUser.GetUserCart().GetItems()[1], -100); commonUser.IncreaseBalance(100000); var BuyItems = commonUser.GetUserCart().GetItems(); // test buy when all is ok Assert.AreEqual(testStore.BuyCart(commonUser.GetUserId()), BuyItems); testStore.AddItemIntoUserCart(commonUser, items[0].Copy(1)); testStore.AddItemIntoUserCart(commonUser, items[1].Copy(1)); testStore.AddItemIntoUserCart(commonUser, items[2].Copy(1)); // test items count after buy Assert.Throws <Store.NotEnoughItemsException>(() => testStore.BuyCart(commonUser.GetUserId())); // test balance after buy Assert.AreEqual(commonUser.GetBalance(), 69900); }