private static IEnumerable <decimal> GetTwoIntegerOperationsSolutionsOrderDoesMatter(IReadOnlyList <int> userPickedNumbers)
        {
            var generatedPossibleSolutions = new List <decimal>();

            var userPickedNumbersOrderOne = userPickedNumbers.ToList();
            var userPickedNumbersOrderTwo = new List <int>
            {
                userPickedNumbers[1],
                userPickedNumbers[0]
            };

            var userPickedNumbersListInArrangedOrderList = new List <List <int> >
            {
                userPickedNumbersOrderOne,
                userPickedNumbersOrderTwo
            };

            foreach (var userPickedNumbersList in userPickedNumbersListInArrangedOrderList)
            {
                var numberOne = userPickedNumbersList[0];
                var numberTwo = userPickedNumbersList[1];

                //for (var index = 1; index <= userPickedNumbersList.Count(); index++)
                //{
                var differenceOfNumberOneNumberTwo = TwoIntegerOperations.Subtract(numberOne, numberTwo);
                var quotientOfNumberOneNumberTwo   = TwoIntegerOperations.Divide(numberOne, numberTwo);

                generatedPossibleSolutions.Add(differenceOfNumberOneNumberTwo);
                generatedPossibleSolutions.Add(quotientOfNumberOneNumberTwo);
                //}
            }

            //ToDo: the loop is generating too much data, for two integers should return 4 operations, instead it is returning 8
            return(generatedPossibleSolutions);
        }
示例#2
0
        public void CanDivideAndGenerateDecimal()
        {
            const int     divisor          = 1;
            const int     dividend         = 2;
            const decimal expectedQuotient = 0.5m;

            var actualQuotient = TwoIntegerOperations.Divide(divisor, dividend);

            Assert.Equal(expectedQuotient, actualQuotient);
        }
示例#3
0
        public void CanDivide()
        {
            const int divisor          = 6;
            const int dividend         = 2;
            const int expectedQuotient = 3;

            var actualQuotient = TwoIntegerOperations.Divide(divisor, dividend);

            Assert.Equal(expectedQuotient, actualQuotient);
        }