Ejemplo n.º 1
0
        public void Should_Return_Exactly_Length()
        {
            int  length = 2;
            long numb   = NumberGenerator.GeneratePositiveLong(length);

            Assert.Equal(length, numb.ToString().Length);
        }
        public void GeneratePositiveLong_ValidArgument_ReturnsANumberWithAGivenNumberOfDigits(int testArgument)
        {
            //arrange

            //act
            long result = NumberGenerator.GeneratePositiveLong(testArgument);

            //assert
            result.ToString().Should().HaveLength(testArgument);
        }
        public void GeneratePositiveLong_InvalidArgument_ThrowsArgumentOutOfRangeException(int testArgument)
        {
            //arrange

            //act
            Action act = () => NumberGenerator.GeneratePositiveLong(testArgument);

            //assert
            act.Should().ThrowExactly <ArgumentOutOfRangeException>().WithMessage("Length must be positive value (Parameter 'length')");
        }
Ejemplo n.º 4
0
        public void GeneratePositiveLong_Should_Retur_Valid_Length()
        {
            var expectedLength = NumberGenerator.GeneratePositiveLong(3).ToString().Length;
            var length         = NumberGenerator.GeneratePositiveLong(3).ToString().Length;

            Assert.Equal(expectedLength, length);
            Assert.Equal(3, length);
            for (int i = 1; i < 19; i++)
            {
                //Assert.Equal(i, NumberGenerator.GeneratePositiveLong(i).ToString().Length);
                Assert.True(NumberGenerator.GeneratePositiveLong(i).ToString().Length == i);
            }
        }
Ejemplo n.º 5
0
 public void GeneratePositiveLong_Should_Fail_If_Argument_Invalid()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => NumberGenerator.GeneratePositiveLong(-4));
     Assert.Throws <ArgumentOutOfRangeException>(() => NumberGenerator.GeneratePositiveLong(0));
     Assert.Throws <ArgumentOutOfRangeException>(() => NumberGenerator.GeneratePositiveLong(19));
 }
Ejemplo n.º 6
0
        public void GeneratePositiveLong_Returns_Number_With_LengthFromArgument(int length)
        {
            var actual = NumberGenerator.GeneratePositiveLong(length).ToString().Length;

            Assert.Equal(length, actual);
        }
Ejemplo n.º 7
0
 public void GeneratePositiveLong_Throws_ArgumentOutOfRangeException_If_Parameter_Invalid(int length)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => NumberGenerator.GeneratePositiveLong(length));
 }
Ejemplo n.º 8
0
        public void ReturnNumberWithGivenNumberOfCharacters(int length)
        {
            int lengthAfter = NumberGenerator.GeneratePositiveLong(length).ToString().Length;

            Assert.Equal(lengthAfter, length);
        }
Ejemplo n.º 9
0
        public void IfArgumentIsInvalidThrowArgumentException(int length)
        {
            var action = new Action(() => NumberGenerator.GeneratePositiveLong(length));

            Assert.ThrowsAny <ArgumentException>(action);
        }
Ejemplo n.º 10
0
 public void Should_Throw_ArgumentException()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => NumberGenerator.GeneratePositiveLong(-2));
 }
Ejemplo n.º 11
0
        public void ReturnNumberLongAsArgument()
        {
            var length = new Random().Next(1, 10);

            Assert.Equal(NumberGenerator.GeneratePositiveLong(length).ToString().Length, length);
        }
Ejemplo n.º 12
0
 public void ThrowExceptionWhenArgumentIsNotValid()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => NumberGenerator.GeneratePositiveLong(-1));
     Assert.Throws <ArgumentOutOfRangeException>(() => NumberGenerator.GeneratePositiveLong(20));
 }