Exemplo n.º 1
0
        public void GenerateFavoriteNumber_Returns_Generated_Number()
        {
            // Arrange
            var numberGeneratorMock = Substitute.For <INumberGenerator>();

            numberGeneratorMock.GetRandom(Arg.Any <int>(), Arg.Any <int>()).Returns(13);
            var subject = new LuckyNumberService(numberGeneratorMock);

            // Act
            var result = subject.GenerateFavoriteNumber();

            // Assert
            Assert.Equal(13, result);
        }
Exemplo n.º 2
0
        public void GenerateFavoriteNumber_Throws_ArgumentOutOfRangeException_When_Min_Is_Less_Then_1()
        {
            // Arrange
            var numberGeneratorMock = Substitute.For <INumberGenerator>();
            var subject             = new LuckyNumberService(numberGeneratorMock);

            // Act
            void Action()
            {
                subject.GenerateFavoriteNumber(-1);
            }

            // Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => Action());
        }