public void when_unsubscribing_with_unknown_buyerid_then_error_message() { var buyer = new BuyerBuilder().WithId(99699999).Build(); var buyerRepoMock = new Mock<IBuyerRepository>(); buyerRepoMock.Expect(br => br.FindNoAuth(buyer.Id)).Throws(new Model.ModelServices.AssertionException("")); var controller = new BuyerController(buyerRepoMock.Object, null, null, ServiceBuilder.Saver.Object); ActionResult result = controller.Unsubscribe(buyer.Id, buyer.UnsubscribeToken); buyerRepoMock.VerifyAll(); }
public void when_unsubscribing_with_wrong_token_then_error_message() { var buyer = new BuyerBuilder().Build(); var buyerRepoMock = new Mock<IBuyerRepository>(); buyerRepoMock.Expect(br => br.FindNoAuth(buyer.Id)).Returns(buyer); var controller = new BuyerController(buyerRepoMock.Object, null, null, ServiceBuilder.Saver.Object); ViewResult result = (ViewResult)controller.Unsubscribe(buyer.Id, "wrong_token"); UnsubscribeResult data = (UnsubscribeResult)result.ViewData.Model; Assert.AreEqual("Unsubscribed", result.ViewName); Assert.IsFalse(data.Success); Assert.AreEqual(buyer.FullName, data.BuyerName); Assert.AreEqual(buyer.Id, data.BuyerId); Assert.IsTrue(((string)result.TempData[SharedHelper.TempDataKeys.errorMsg.ToString()]).Length > 0); Assert.IsNull(result.TempData[SharedHelper.TempDataKeys.success.ToString()]); }