コード例 #1
0
        public void GetProductBySkuWithMissingSkuReturnsNull()
        {
            TestableProductCatalog target = new TestableProductCatalog();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            Product product = target.GetProductBySku("XXXXXXXXXX");

            Assert.IsNull(product);
        }
コード例 #2
0
        public void CanGetProductBySku()
        {
            Isolate.WhenCalled(() => HttpContext.Current.Request.Url.Scheme).WillReturn("http");
            Isolate.WhenCalled(() => HttpContext.Current.Server.MachineName).WillReturn("localhost");
            Isolate.WhenCalled(() => HttpContext.Current.Request.Url.Port).WillReturn(8585);
            Isolate.WhenCalled(() => HttpContext.Current.Request.Url.Segments).WillReturn(new string[] { "/", "Contoso.LOB.Services/", "service.svc" });
            TestableProductCatalog target = new TestableProductCatalog();

            target.ReplacementSecurityHelper = mockSecurityHelper;

            Product product = target.GetProductBySku("1000000000");

            Assert.AreEqual("Blood Pressure Kit", product.Name);
            Assert.AreEqual("http://localhost:8585/Contoso.LOB.Services/images/bloodpressure.jpg", product.ImagePath);
            Assert.AreEqual("http://localhost:8585/Contoso.LOB.Services/images/bloodpressure.jpg", product.ThumbnailImagePath);
            Assert.AreEqual("Blood pressure kit includes cuff and easy to read dial.", product.ShortDescription);
            Assert.AreEqual("Blood pressure kit includes cuff with velcro adhesive and easy to read glow in the dark dial.", product.LongDescription);
            Assert.AreEqual("1000000000", product.Sku);
        }