public void SetsDtoValuesFromUri()
            {
                // Arrange
                const string expectedProductKey   = "p12345";
                const string expectedAttributeKey = "asta";
                var          postData             = new SetChileProductAttributeRangesRequest
                {
                    AttributeRanges = new List <AttributeRangeRequest>
                    {
                        new AttributeRangeRequest
                        {
                            AttributeNameKey = expectedAttributeKey
                        }
                    }
                };
                ISetChileProductAttributeRangesParameters actualParams = null;

                MockProductService.Setup(
                    m => m.SetChileProductAttributeRanges(It.IsAny <ISetChileProductAttributeRangesParameters>()))
                .Callback((ISetChileProductAttributeRangesParameters p) => actualParams = p)
                .Returns(new SuccessResult());

                // Act
                SystemUnderTest.Post(expectedProductKey, postData);

                // Assert
                Assert.AreEqual(expectedProductKey, actualParams.ChileProductKey);
                Assert.AreEqual(expectedAttributeKey, actualParams.AttributeRanges.Single().AttributeNameKey);
            }
示例#2
0
        public IResult SetChileProductAttributeRange(ISetChileProductAttributeRangesParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var parsedParameters = parameters.ToParsedParameters();

            if (!parsedParameters.Success)
            {
                return(parsedParameters.ConvertTo <string>());
            }

            var setResult = new SetChileProductAttributeRangesCommand(_productUnitOfWork).Execute(parsedParameters.ResultingObject, _timeStamper.CurrentTimeStamp);

            if (!setResult.Success)
            {
                return(setResult.ConvertTo <string>());
            }

            _productUnitOfWork.Commit();

            return(SyncParameters.Using(new SuccessResult(),
                                        new SyncProductParameters
            {
                ProductKey = setResult.ResultingObject.ToProductKey()
            }));
        }
示例#3
0
 public IResult SetChileProductAttributeRanges(ISetChileProductAttributeRangesParameters parameters)
 {
     try
     {
         return(_productServiceProvider.SetChileProductAttributeRange(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult <string>(null, ex.Message));
     }
 }
            public void UtilizesUserIdentityProvider()
            {
                // Arrange
                const string expectedProductKey = "p12345";
                var          postData           = Fixture.Create <SetChileProductAttributeRangesRequest>();
                ISetChileProductAttributeRangesParameters actual = null;

                MockProductService.Setup(m => m.SetChileProductAttributeRanges(It.IsAny <ISetChileProductAttributeRangesParameters>()))
                .Callback((ISetChileProductAttributeRangesParameters param) => actual = param)
                .Returns(new SuccessResult());

                // Act
                SystemUnderTest.Post(expectedProductKey, postData);

                // Assert
                Assert.IsNotNull(actual);
                UserIdentityProviderMock.Verify(m => m.SetUserIdentity(actual), Times.Once());
            }
示例#5
0
        internal static IResult <SetChileProductAttributeRangesCommandParameters> ToParsedParameters(this ISetChileProductAttributeRangesParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var chileProductKey = KeyParserHelper.ParseResult <IChileProductKey>(parameters.ChileProductKey);

            if (!chileProductKey.Success)
            {
                return(chileProductKey.ConvertTo((SetChileProductAttributeRangesCommandParameters)null));
            }

            var attributeRanges = new List <SetChileProductAttributeRangeParameters>();

            foreach (var range in parameters.AttributeRanges ?? new List <ISetAttributeRangeParameters>())
            {
                var rangeResult = range.ToParsedParameters();
                if (!rangeResult.Success)
                {
                    return(rangeResult.ConvertTo <SetChileProductAttributeRangesCommandParameters>());
                }

                attributeRanges.Add(rangeResult.ResultingObject);
            }

            return(new SuccessResult().ConvertTo(new SetChileProductAttributeRangesCommandParameters
            {
                Parameters = parameters,
                ChileProductKey = chileProductKey.ResultingObject.ToChileProductKey(),
                AttributeRanges = attributeRanges
            }));
        }