Exemple #1
0
 public void unsubscribe_token_is_always_the_same()
 {
     Buyer b1 = new BuyerBuilder().Build();
     Buyer b2 = new BuyerBuilder().Build();
     Console.WriteLine(b1.UnsubscribeToken);
     Assert.AreEqual(b1.UnsubscribeToken, b2.UnsubscribeToken);
 }
Exemple #2
0
 public void when_buyers_have_different_emails_then_unsubscribe_token_is_different()
 {
     Buyer b1 = new BuyerBuilder().WithEmail("*****@*****.**").Build();
     Buyer b2 = new BuyerBuilder().Build();
     Console.WriteLine(b1.UnsubscribeToken);
     Console.WriteLine(b2.UnsubscribeToken);
     Assert.AreNotEqual(b1.UnsubscribeToken, b2.UnsubscribeToken);
 }
        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();
        }
Exemple #4
0
        public void ValidateEmail()
        {
            var b = new BuyerBuilder().WithEmail(null).Build();
            AssertInvalidWithAtLeastOneErrorOnProperty(b, "Email");

            b = new BuyerBuilder().WithEmail(String.Empty).Build();
            Assert.IsTrue(b.IsValid);
            Assert.AreEqual(0, b.Errors.Count);

            b = new BuyerBuilder().WithEmail("*****@*****.**").Build();
            AssertIsValid(b);

            b = new BuyerBuilder().WithEmail("steviegmail.com").Build();
            AssertInvalidWithAtLeastOneErrorOnProperty(b, "Email");
        }
        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()]);
        }
Exemple #6
0
        public void ValidateLastName()
        {
            var b = new BuyerBuilder().WithLastName(null).Build();
            AssertInvalidWithAtLeastOneErrorOnProperty(b, "LastName");

            b = new BuyerBuilder().WithLastName(String.Empty).Build();
            AssertIsValid(b);

            b = new BuyerBuilder().WithLastName(GetCharacters(50)).Build();
            AssertIsValid(b);
            b = new BuyerBuilder().WithLastName(GetCharacters(100)).Build();
            AssertIsValid(b);

            b = new BuyerBuilder().WithLastName(GetCharacters(101)).Build();
            AssertInvalidWithAtLeastOneErrorOnProperty(b, "LastName");
        }
Exemple #7
0
        public void when_preference_does_match_productattribute_then_match()
        {
            var housePrice = new MetaAttributeBuilder().HousePrice(); // Currency / Range

            var product = new ProductBuilder().Product440000;
            var buyer = new BuyerBuilder().Build();
            buyer.Preferences.Add(new PreferenceBuilder().WithMetaAttribute(housePrice).WithRawValues("30000000-45000000").Build());
            Assert.IsTrue(buyer.IsMatch(product));
        }
Exemple #8
0
        public void when_product_has_no_productattributes_then_everything_matches()
        {
            var products = new ProductBuilder().GetCollectionOfProductsWithNoProductAttributes().ToList();
            var buyer = new BuyerBuilder().Build();

            products.ForEach(p => Assert.IsTrue(buyer.IsMatch(p)));

            buyer.Preferences.Add(new PreferenceBuilder().WithMetaAttribute(new MetaAttributeBuilder().HousePrice()).Build());
            products.ForEach(p => Assert.IsTrue(buyer.IsMatch(p)));
        }