public IEnumerator GetAmount() { yield return(TestInitConditions()); TestProduct p = new TestProduct(1, "a"); TestProduct p2 = new TestProduct(2, "b"); IProduct[] toRegister = new IProduct[] { p }; wallet.RegisterProducts(toRegister, true); wallet.ChangeAmount(p, 1); uint amount1 = wallet.GetAmount(p); uint amount2 = wallet.GetAmount(p.GetProductId()); LogAssert.Expect(LogType.Error, "Product 2 not properly registered"); uint amount3 = wallet.GetAmount(p2); LogAssert.Expect(LogType.Error, "Product 2 not properly registered"); uint amount4 = wallet.GetAmount(p2.GetProductId()); Assert.True(amount1 == 1, "Unexpected Amount"); Assert.True(amount2 == 1, "Unexpected Amount"); Assert.True(amount3 == 0, "Unexpected Amount"); Assert.True(amount4 == 0, "Unexpected Amount"); }
public IEnumerator AddDuplicateProducts() { yield return(TestInitConditions()); yield return(TestInitConditions()); TestProduct p = new TestProduct(1, "a"); TestProduct p2 = new TestProduct(p.GetProductId(), "b"); IProduct[] toRegister = new IProduct[] { p, p, p2 }; LogAssert.Expect(LogType.Error, "Trying to register duplicate products for ID 1"); LogAssert.Expect(LogType.Error, "Trying to register duplicate products for ID 1"); wallet.RegisterProducts(toRegister, true); LogAssert.Expect(LogType.Error, "Trying to register duplicate products for ID 1"); wallet.RegisterProduct(p); LogAssert.Expect(LogType.Error, "Trying to register duplicate products for ID 1"); wallet.RegisterProduct(p2); }