Beispiel #1
0
        public void GivenMiningAttemptFails_ResultDoesNotIncludeCoin()
        {
            // Arrange
            var mockMathService = new Mock <IMathService>();

            mockMathService.Setup(x => x.IsPrime(It.IsAny <int>())).Returns(() => false);
            var sut = new MiningService(mockMathService.Object);

            // Act
            var actualResult = sut.AttemptMineNewCoin();

            // Assert
            Assert.False(actualResult.CoinCreated);
            Assert.Null(actualResult.NewCoin);
        }
Beispiel #2
0
        public void GivenPrimeNumCalcSuccessful_ThenNewCoinReturned()
        {
            // Arange
            var mathMock = new Mock <IMathService>();

            mathMock.Setup(x => x.IsPrime(It.IsAny <int>())).Returns(true);
            var miningService = new MiningService(mathMock.Object);

            // Act
            var result = miningService.AttemptMineNewCoin();

            // Assert
            Assert.True(result.CoinCreated);
            Assert.NotNull(result.NewCoin);
        }
Beispiel #3
0
        public void GivenMiningAttemptSuccessful_ResultIncludesNewlyMintedCoin()
        {
            // Arrange
            var mockMathService = new Mock <IMathService>();

            mockMathService.Setup(x => x.IsPrime(It.IsAny <int>())).Returns(() => true);
            var sut = new MiningService(mockMathService.Object);

            // Act
            var actualResult = sut.AttemptMineNewCoin();

            // Assert
            Assert.True(actualResult.CoinCreated);
            Assert.NotNull(actualResult.NewCoin);
            Assert.IsType <Coin>(actualResult.NewCoin);
        }
 public MiningController(MiningService miningService)
 {
     _miningService = miningService;
 }