示例#1
0
        public void Convert_NegativeSimpleNumber_ThrowsArgumentException()
        {
            var adder = new Adder();

            Expect(() => adder.Convert("-100"), Throws.ArgumentException);
            Expect(() => adder.Convert("100-"), Throws.ArgumentException);
            Expect(() => adder.Convert("100-"), Throws.ArgumentException);
        }
示例#2
0
        public void Convert_Null_ThrowsArgumentNullException()
        {
            var adder = new Adder();

            Expect(() => adder.Convert(null), Throws.ArgumentNullException
                   .With.Message.Contains("Empty")
                   .And.Property("ParamName").Contains("amount"));
        }
示例#3
0
        public void Convert_CorrectComplexNumber_ConvertsItToDecimalOfSum()
        {
            var adder = new Adder();

            var actual = adder.Convert("100 + 100");

            Expect(actual, EqualTo(200m));
        }
示例#4
0
        public void Convert_PositiveSimpleNumber_ConvertsItToDecimal()
        {
            var adder = new Adder();

            var actual = adder.Convert("100");

            Expect(actual, EqualTo(100m));
        }
示例#5
0
        public void Convert_NegativeComplexNumber_ThrowsArgumentException()
        {
            var adder = new Adder();

            Expect(() => adder.Convert("-100"), Throws.ArgumentException
                   .With.Message.Contains("Negative")
                   .And.Property("ParamName").Contains("sum"));

            Expect(() => adder.Convert("100-"), Throws.ArgumentException
                   .With.Message.Contains("Negative")
                   .And.Property("ParamName").Contains("sum"));

            Expect(() => adder.Convert("-100 + 20"), Throws.ArgumentException
                   .With.Message.Contains("Negative")
                   .And.Property("ParamName").Contains("sum"));

            Expect(() => adder.Convert("-100 + -20"), Throws.ArgumentException
                   .With.Message.Contains("Negative")
                   .And.Property("ParamName").Contains("sum"));
        }
示例#6
0
        public void Convert_IncorrectComplexNumber_ThrowsFormatException()
        {
            var adder = new Adder();

            Expect(() => adder.Convert("100 + "), Throws.TypeOf <FormatException>());
            Expect(() => adder.Convert("100+ "), Throws.TypeOf <FormatException>());
            Expect(() => adder.Convert("100+"), Throws.TypeOf <FormatException>());
            Expect(() => adder.Convert("-100-"), Throws.TypeOf <FormatException>());
            Expect(() => adder.Convert("awd"), Throws.TypeOf <FormatException>());
            Expect(() => adder.Convert("+@#$"), Throws.TypeOf <FormatException>());
        }