Exemplo n.º 1
0
        public void ShouldParseWithNegativeValue()
        {
            string barLine  = "#A:RED:-5";
            Bar    expected = new Bar {
                Name = "A", Colour = Color.Red, Value = -5
            };
            IParser parser = new SnowParser();

            var result = parser.Parse(barLine);

            Assert.IsTrue(expected.Equals(result));
        }
Exemplo n.º 2
0
        public void ShouldFailWhenNameIsNotAlphaNumeric()
        {
            string    barLine    = "#A/:RED:5";
            IParser   parser     = new SnowParser();
            Exception expectedEx = null;

            try
            {
                var result = parser.Parse(barLine);
            }
            catch (Exception ex)
            {
                expectedEx = ex;
            }

            Assert.IsNotNull(expectedEx);
            Assert.IsInstanceOfType(expectedEx, typeof(ArgumentException));
            Assert.AreEqual(expectedEx.Message, "Name Should Be Alphanumeric\r\nParameter name: name");
        }
Exemplo n.º 3
0
        public void ShouldFailWithNoHash()
        {
            string    barLine    = "A:RED:5";
            IParser   parser     = new SnowParser();
            Exception expectedEx = null;

            try
            {
                var result = parser.Parse(barLine);
            }
            catch (Exception ex)
            {
                expectedEx = ex;
            }

            Assert.IsNotNull(expectedEx);
            Assert.IsInstanceOfType(expectedEx, typeof(ArgumentException));
            Assert.AreEqual(expectedEx.Message, "BarLine should start with '#'\r\nParameter name: barLine");
        }
Exemplo n.º 4
0
        public void ShouldFailWithNull()
        {
            string    barLine    = null;
            IParser   parser     = new SnowParser();
            Exception expectedEx = null;

            try
            {
                var result = parser.Parse(barLine);
            }
            catch (Exception ex)
            {
                expectedEx = ex;
            }

            Assert.IsNotNull(expectedEx);
            Assert.IsInstanceOfType(expectedEx, typeof(ArgumentNullException));
            Assert.AreEqual(expectedEx.Message, "Value cannot be null.\r\nParameter name: barLine");
        }
Exemplo n.º 5
0
        public void ShouldFailWhenValueIsNotInteger()
        {
            string    barLine    = "#A:RED:five";
            IParser   parser     = new SnowParser();
            Exception expectedEx = null;

            try
            {
                var result = parser.Parse(barLine);
            }
            catch (Exception ex)
            {
                expectedEx = ex;
            }

            Assert.IsNotNull(expectedEx);
            Assert.IsInstanceOfType(expectedEx, typeof(ArgumentException));
            Assert.AreEqual(expectedEx.Message, "Bar Value should be a integer\r\nParameter name: value");
        }
Exemplo n.º 6
0
        public void ShouldFailWhenColourIsInvalid()
        {
            string    barLine    = "#A:NotAColour:5";
            IParser   parser     = new SnowParser();
            Exception expectedEx = null;

            try
            {
                var result = parser.Parse(barLine);
            }
            catch (Exception ex)
            {
                expectedEx = ex;
            }

            Assert.IsNotNull(expectedEx);
            Assert.IsInstanceOfType(expectedEx, typeof(ArgumentException));
            Assert.AreEqual(expectedEx.Message, "NotAColour is not a valid colour");
        }