Exemplo n.º 1
0
        public void GetDiscountsByProductSkuTest()
        {
            mockSecurityHelper.UserToReturn = "ContosoPartner1";

            TestablePricing target = new TestablePricing();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            int     expectedCount      = 1;
            string  expectedId         = "1";
            string  expectedPartnerId  = "ContosoPartner1";
            string  expectedProductSku = "1000000000";
            string  expectedName       = "2 for 1";
            decimal expectedValue      = 50M;

            IList <Discount> actual;

            actual = target.GetDiscountsBySku("1000000000");

            Assert.AreEqual(expectedCount, actual.Count);
            Assert.AreEqual(expectedId, actual[0].Id);
            Assert.AreEqual(expectedPartnerId, actual[0].PartnerId);
            Assert.AreEqual(expectedProductSku, actual[0].ProductSku);
            Assert.AreEqual(expectedName, actual[0].Name);
            Assert.AreEqual(expectedValue, actual[0].Value);
        }
Exemplo n.º 2
0
        public void GetPricePriceNotFoundTest()
        {
            mockSecurityHelper.UserToReturn = "ContosoPartner1";

            TestablePricing target = new TestablePricing();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            Price actual = target.GetPriceBySku("99999");

            Assert.IsNull(actual);
        }
Exemplo n.º 3
0
        public void GetDiscountByIdDiscountNotFoundTest()
        {
            mockSecurityHelper.UserToReturn = "ContosoPartner1";

            TestablePricing target = new TestablePricing();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            Discount actual;

            actual = target.GetDiscountById("9999");

            Assert.AreEqual(null, actual);
        }
Exemplo n.º 4
0
        public void GetDiscountsByProductDiscountsNotFoundTest()
        {
            mockSecurityHelper.UserToReturn = "ContosoPartner1";

            TestablePricing target = new TestablePricing();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            int expectedCount = 0;

            IList <Discount> actual;

            actual = target.GetDiscountsBySku("9999");

            Assert.AreEqual(expectedCount, actual.Count);
        }
Exemplo n.º 5
0
        public void GetPriceForUnknownPartnerReturnsBasePrice()
        {
            mockSecurityHelper.UserToReturn = "999";

            TestablePricing target = new TestablePricing();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            Price expected = new Price();

            expected.ProductSku = "1000000000";
            expected.PartnerId  = "999";
            expected.Value      = 319.99M;

            Price actual;

            actual = target.GetPriceBySku(expected.ProductSku);

            Assert.AreEqual(expected.ProductSku, actual.ProductSku);
            Assert.AreEqual(expected.PartnerId, actual.PartnerId);
            Assert.AreEqual(expected.Value, actual.Value);
        }
Exemplo n.º 6
0
        public void GetPriceForKnownPartnerAppliesDiscounts()
        {
            mockSecurityHelper.UserToReturn = "ContosoPartner1";

            TestablePricing target = new TestablePricing();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            Price expected = new Price();

            expected.ProductSku = "1000000000";
            expected.PartnerId  = "ContosoPartner1";
            expected.Value      = 159.995M; // 319.99 / 2

            Price actual;

            actual = target.GetPriceBySku(expected.ProductSku);

            Assert.AreEqual(expected.ProductSku, actual.ProductSku);
            Assert.AreEqual(expected.PartnerId, actual.PartnerId);
            Assert.AreEqual(expected.Value, actual.Value);
        }
Exemplo n.º 7
0
        public void GetDiscountByIdTest()
        {
            mockSecurityHelper.UserToReturn = "ContosoPartner1";

            TestablePricing target = new TestablePricing();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            string expectedId         = "1";
            string expectedPartnerId  = "ContosoPartner1";
            string expectedProductSku = "1000000000";
            string expectedName       = "2 for 1";

            Discount actual;

            actual = target.GetDiscountById("1");

            Assert.AreEqual(expectedId, actual.Id);
            Assert.AreEqual(expectedPartnerId, actual.PartnerId);
            Assert.AreEqual(expectedProductSku, actual.ProductSku);
            Assert.AreEqual(expectedName, actual.Name);
        }