Example #1
0
        public void Should_add_computed_value_to_cache()
        {
            // Arrange
            var calculationServiceMock = new Mock <ICalculationService>();

            calculationServiceMock.Setup(x => x.Calculate(It.IsAny <decimal>(), It.IsAny <decimal>()))
            .Returns(ComputedResult);

            var sut = new CachedCalculationService(calculationServiceMock.Object);

            // Act
            var firstCall  = sut.Calculate(FirstParameter, SecondParameter);
            var secondCall = sut.Calculate(FirstParameter, SecondParameter);

            // Assert
            calculationServiceMock.Verify(x => x.Calculate(FirstParameter, SecondParameter), Times.Once);
        }