コード例 #1
0
 public void ConvertOne()
 {
     BinaryValidator binaryValidator = new BinaryValidator();
     BinaryConverter binaryConverter = new BinaryConverter(binaryValidator);
     int convertedValue = binaryConverter.ConvertToDecimalNumber("1");
     Assert.That(convertedValue == 1);
 }
コード例 #2
0
 public void ConvertNumberShouldSucceed(string binaryNumber, int result)
 {
     BinaryValidator binaryValidator = new BinaryValidator();
     BinaryConverter binaryConverter = new BinaryConverter(binaryValidator);
     int convertedValue = binaryConverter.ConvertToDecimalNumber(binaryNumber);
     Assert.That(convertedValue == result);
 }
コード例 #3
0
 public void ThrowsArgumentExceptionWhenParameterIsNotBinaryNumber()
 {
     IBinaryValidator binaryValidator = new BinaryValidatorAlwaysInvalid();
     BinaryConverter binaryConverter = new BinaryConverter(binaryValidator);
     Assert.Throws<ArgumentException>(
         () => binaryConverter.ConvertToDecimalNumber("a")
         );
 }
コード例 #4
0
        public void ThrowsArgumentExceptionWhenParameterIsNotBinaryNumberVersionWithRhinoMocks()
        {
            IBinaryValidator binaryValidator = MockRepository.GenerateStub<IBinaryValidator>();
            binaryValidator.Stub(x => x.IsValidBinaryNumber(Arg<string>.Is.Anything))
                .Return(false);

            BinaryConverter binaryConverter = new BinaryConverter(binaryValidator);
            Assert.Throws<ArgumentException>(
                () => binaryConverter.ConvertToDecimalNumber("a")
                );
        }