Пример #1
0
        public void CopyProductSKUFieldsToSKU_ShouldLogException_WhenProductProviderFails()
        {
            var sut = new ProductEventHandlerFake()
            {
                Product = new ProductClass()
            };
            var productProviderStub = new Mock <IKenticoProductsProvider>();

            productProviderStub.Setup(p => p.UpdateSku(It.IsAny <Sku>())).Throws(new Exception());
            sut.ProductsProvider = productProviderStub.Object;
            var loggerMock = new Mock <IKenticoLogger>();

            sut.Logger = loggerMock.Object;

            sut.CopyProductSKUFieldsToSKU_EventHandler(sut, new DocumentEventArgs());

            loggerMock.Verify(l => l.LogException(It.IsAny <string>(), It.IsAny <Exception>()), Times.Once());
        }
Пример #2
0
        public void CopyProductSKUFieldsToSKU_ShouldCopyValues_WhenNodeIsProduct()
        {
            var product = new ProductClass
            {
                NodeSKUID        = 1,
                SKUNeedsShipping = true,
                SKUWeight        = 2
            };
            var sut = new ProductEventHandlerFake()
            {
                Product = product
            };
            var productProviderMock = new Mock <IKenticoProductsProvider>();

            sut.ProductsProvider = productProviderMock.Object;

            sut.CopyProductSKUFieldsToSKU_EventHandler(sut, new DocumentEventArgs());

            productProviderMock.Verify(p => p.UpdateSku(It.Is <Sku>(s
                                                                    => s.SkuId == product.NodeSKUID &&
                                                                    s.NeedsShipping == product.SKUNeedsShipping &&
                                                                    s.Weight == product.SKUWeight)));
        }