public void ItShouldCalculationServiceTraversalMethod() { var input = new[] { 1, 2, 3, 4 }; var response = Sut.Traverse(input); // Checking if it was called with correct params and with any params only once CalculationServiceMock.Verify(m => m.Traverse(It.IsAny <int[]>()), Times.Once); CalculationServiceMock.Verify(m => m.Traverse(It.Is((int[] path) => path.Equals(input))), Times.Once); response.Should().Be(_graph); }
public void ItShouldOnlyCallCalculationServiceTraversalMethodOnceIfItemIsCached() { object value; MemoryCacheMock.SetupSequence(m => m.TryGetValue(It.IsAny <object>(), out value)) .Returns(false) .Returns(true); var input = new[] { 1, 2, 3, 4 }; var response = Sut.Traverse(input); // Checking if it was called with correct params and with any params only once CalculationServiceMock.Verify(m => m.Traverse(It.IsAny <int[]>()), Times.Once); CalculationServiceMock.Verify(m => m.Traverse(It.Is((int[] path) => path.Equals(input))), Times.Once); response.Should().Be(_graph); }