コード例 #1
0
        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 CanSubtract()
        {
            const int minuend            = 3;
            const int subtrahend         = 2;
            const int expectedDifference = 1;

            var actualDifference = TwoIntegerOperations.Subtract(minuend, subtrahend);

            Assert.Equal(expectedDifference, actualDifference);
        }