示例#1
0
        public void CalculateSignatureSizeValue_IFArgumentSatisfied_SignatureSizeLengthAndWidthEqualReturnValuesFromManager()
        {
            _mockView.SetupProperty(r => r.PageCount, 2);
            _mockView.SetupProperty(r => r.PagesPerSignature, "2pg");
            _mockView.SetupProperty(r => r.PageSizeLength, 5);
            _mockView.SetupProperty(r => r.PageSizeWidth, 10);
            _mockView.SetupProperty(r => r.SignatureSizeWidth);
            _mockView.SetupProperty(r => r.Bleeds);
            _mockView.SetupProperty(r => r.SignatureSizeLength);;
            SignatureSizeLength sigLength = new SignatureSizeLength("2pg", 4, 5, 5);
            SignatureSizeWidth  sigWidth  = new SignatureSizeWidth("2pg", 4, 5, 5);

            _mockSystemVariablesManager.Setup(r => r.ReturnNudVariables())
            .Returns(new PrintingAppRepository.SystemVariables.Models.SystemVariables());

            _mockImpositionCalculatorManager.Setup(r => r.ReturnSignatureSizeLength(It.IsAny <SignatureSizeLength>()))
            .Returns(5);

            _mockImpositionCalculatorManager.Setup(r => r.ReturnSignatureSizeWidth(It.IsAny <SignatureSizeWidth>()))
            .Returns(15.2F);

            _mockView.Raise(r => r.CalculateSignatureSize += null, new EventArgs());

            Assert.IsTrue(_mockView.Object.SignatureSizeLength == _mockImpositionCalculatorManager.Object.ReturnSignatureSizeLength(sigLength) &&
                          _mockView.Object.SignatureSizeWidth == _mockImpositionCalculatorManager.Object.ReturnSignatureSizeWidth(sigWidth));
        }
        public float ReturnSignatureSizeWidth(SignatureSizeWidth widthParameters)
        {
            //Regex to only pull ints
            int amountOfPages = int.Parse(Regex.Match(widthParameters.PagesPerSignature, "\\d+")
                                          .Value);

            if (widthParameters.PagesPerSignature.Contains("right angle"))
            {
                if (amountOfPages <= 12)
                {
                    widthParameters.ValueOneMultiplier  = 2;
                    widthParameters.ValueTwoMultiplier  = 2;
                    widthParameters.ValueThreeMultipler = 1;
                }
                else
                {
                    widthParameters.ValueOneMultiplier  = 4;
                    widthParameters.ValueTwoMultiplier  = 4;
                    widthParameters.ValueThreeMultipler = 2;
                }
            }
            else if (widthParameters.PagesPerSignature.Contains("parallel"))
            {
                widthParameters.ValueOneMultiplier  = amountOfPages / 2;
                widthParameters.ValueTwoMultiplier  = amountOfPages / 2;
                widthParameters.ValueThreeMultipler = (int)Math.Floor(amountOfPages / 4D);
            }
            else if (widthParameters.PagesPerSignature.Contains("2up tear apart"))
            {
                widthParameters.ValueOneMultiplier  = 4;
                widthParameters.ValueTwoMultiplier  = 4;
                widthParameters.ValueThreeMultipler = 2;
            }
            else if (widthParameters.PagesPerSignature.Contains("4pg"))
            {
                widthParameters.ValueOneMultiplier = widthParameters.ValueOneMultiplier * 2;
            }

            return((widthParameters.Width * widthParameters.ValueOneMultiplier)
                   + (widthParameters.Bleeds * widthParameters.ValueTwoMultiplier)
                   + (widthParameters.BindingLip * widthParameters.ValueThreeMultipler));
        }