public NonObligatedValuesViewModel Map(ReturnToNonObligatedValuesViewModelMapTransfer source)
        {
            Guard.ArgumentNotNull(() => source, source);

            var viewModel = new NonObligatedValuesViewModel(calculator)
            {
                ReturnId       = source.ReturnId,
                OrganisationId = source.OrganisationId,
                Dcf            = source.Dcf
            };

            var existingData = nonObligatedMap.Map(new NonObligatedDataToNonObligatedValueMapTransfer()
            {
                NonObligatedDataValues = source.ReturnData.NonObligatedData.ToList(), NonObligatedCategoryValues = viewModel.CategoryValues, Dcf = source.Dcf
            });

            if (source.PastedData != null)
            {
                var pastedValues = pasteProcessor.BuildModel(source.PastedData);

                viewModel.CategoryValues = pasteProcessor.ParseNonObligatedPastedValues(pastedValues, existingData);
            }
            else
            {
                viewModel.CategoryValues = existingData;
            }

            return(viewModel);
        }
示例#2
0
        public void Map_GivenPastedData_PasteProcessorShouldBeCalled()
        {
            var pastedList = new List <NonObligatedCategoryValue>();

            for (var i = 0; i < pastedList.Count; i++)
            {
                pastedList[i].Tonnage = i.ToString();
            }

            var transfer = new ReturnToNonObligatedValuesViewModelMapTransfer()
            {
                PastedData = A.Dummy <String>()
            };

            var returnList = new List <ObligatedCategoryValue>();

            A.CallTo(() => pasteProcessor.ParseNonObligatedPastedValues(A <PastedValues> ._, A <IList <NonObligatedCategoryValue> > ._)).Returns(pastedList);

            var result = mapper.Map(transfer);

            result.CategoryValues.Should().BeEquivalentTo(pastedList);
        }