public void TestCase2_CheckFalse() { // Setup MyLogger log = new MyLogger(); MyCouponProvider cp = new MyCouponProvider(); Guid couponId = new Guid("00000000-0000-0000-0000-00000000BA12"); Guid userId = new Guid("00000000-0000-0000-0000-000000001111"); List <Func <Coupon, Guid, bool> > theList = new List <Func <Coupon, Guid, bool> >(); for (int i = 0; i < 10; i++) { CouponGuid temp = new CouponGuid(); theList.Add(temp.Evaluate); } CouponManager cm = new CouponManager(log, cp); // Apply try { Task <bool> task = cm.CanRedeemCoupon(couponId, userId, theList); task.Wait(); bool result = task.Result; // Check Assert.AreEqual(result, false); } catch (Exception e) { Assert.Fail(e.Message); } }
public void TestCase4_CheckCouponIsNull() { // Setup MyLogger log = new MyLogger(); MyCouponProvider cp = new MyCouponProvider(); Guid couponId = new Guid("00000000-0000-0000-0000-000000002222"); Guid userId = new Guid("00000000-0000-0000-0000-000000001111"); List <Func <Coupon, Guid, bool> > theList = new List <Func <Coupon, Guid, bool> >(); for (int i = 0; i < 10; i++) { CouponGuid temp = new CouponGuid(); theList.Add(temp.Evaluate); } CouponManager cm = new CouponManager(log, cp); try { // Apply Task <bool> task = cm.CanRedeemCoupon(couponId, userId, theList); task.Wait(); bool result = task.Result; // Check Assert.Fail("Exception must be thrown"); } catch (Exception e) { Assert.IsTrue(e.Message.Contains("The given key was not present in the dictionary")); } }