public void Build_ReturnsCorrectResponse(string[] termsReplaced, int[] originalNumbers, string expectedResult)
        {
            // Arrange
            var mockSummary = new Dictionary <string, int>();

            // Act
            var replaceInRangeResponse = ReplaceInRangeResponse.Build(termsReplaced, originalNumbers, mockSummary);

            // Assert
            Assert.Equal(expectedResult, replaceInRangeResponse.result);
        }
        public ReplaceInRangeResponse ReplaceInRange([FromQuery(Name = "lowerBound")] int lowerBound, [FromQuery(Name = "upperBound")] int upperBound)
        {
            if (lowerBound > upperBound)
            {
                throw new ArgumentException("lowerBound must be less than or equal to upperBound");
            }

            var range         = Enumerable.Range(lowerBound, (upperBound - lowerBound) + 1).ToArray();
            var termsReplaced = _termReplacer.ReplaceSequence(range);
            var summary       = _summaryBuilder.BuildSummary(termsReplaced, range);

            return(ReplaceInRangeResponse.Build(termsReplaced, range, summary));
        }
        public void ReplaceInRange_WhenValidInput_ReturnsCalculatedResponse(int lowerBound, int upperBound)
        {
            // Arrange
            var mockTermsReplaced   = new[] { "test" };
            var mockSummary         = new Dictionary <string, int>(new[] { new KeyValuePair <string, int>("test", 1) });
            var mockOriginalNumbers = new[] { 1 };
            var expectedResponse    = ReplaceInRangeResponse.Build(mockTermsReplaced, mockOriginalNumbers, mockSummary);

            var termReplacer   = Substitute.For <ITermReplacer>();
            var summaryBuilder = Substitute.For <ISummaryBuilder>();

            termReplacer.ReplaceSequence(Arg.Any <int[]>()).ReturnsForAnyArgs(mockTermsReplaced);
            summaryBuilder.BuildSummary(mockTermsReplaced, Arg.Any <int[]>()).ReturnsForAnyArgs(mockSummary);
            var termReplacementController = new TermReplacementController(termReplacer, summaryBuilder);

            // Act
            var response = termReplacementController.ReplaceInRange(lowerBound, upperBound);

            // Assert
            Assert.True(expectedResponse.result == response.result && expectedResponse.summary == response.summary, "Response from ReplaceInRange action method was different than expected");
        }