Exemplo n.º 1
0
        public static void IsBalanced_SingleCharacterOpenAndCloseMarkersAndSourceIsWhiteSpace_ThrowsArgumentException()
        {
            // Arrange
            int          unbalancedPosition;
            const char   Open    = '(';
            const char   Close   = ')';
            string       source1 = string.Empty;
            const string Source2 = "  ";
            const string Source3 = "  \r\n  ";

            // Act, Assert
            Assert.Throws <ArgumentException>(() => source1.IsBalanced(Open, Close));
            Assert.Throws <ArgumentException>(() => source1.IsBalanced(Open, Close, out unbalancedPosition));

            Assert.Throws <ArgumentException>(() => Source2.IsBalanced(Open, Close));
            Assert.Throws <ArgumentException>(() => Source2.IsBalanced(Open, Close, out unbalancedPosition));

            Assert.Throws <ArgumentException>(() => Source3.IsBalanced(Open, Close));
            Assert.Throws <ArgumentException>(() => Source3.IsBalanced(Open, Close, out unbalancedPosition));
        }
Exemplo n.º 2
0
        public static void IsBalanced_MultipleOpenAndCloseMarkersAndSourceIsWhiteSpace_ThrowsArgumentException()
        {
            // Arrange
            int          unbalancedPosition;
            var          open    = new[] { '(', '[' };
            var          close   = new[] { ')', ']' };
            string       source1 = string.Empty;
            const string Source2 = "  ";
            const string Source3 = "  \r\n  ";

            // Act, Assert
            Assert.Throws <ArgumentException>(() => source1.IsBalanced(open, close));
            Assert.Throws <ArgumentException>(() => source1.IsBalanced(open, close, out unbalancedPosition));

            Assert.Throws <ArgumentException>(() => Source2.IsBalanced(open, close));
            Assert.Throws <ArgumentException>(() => Source2.IsBalanced(open, close, out unbalancedPosition));

            Assert.Throws <ArgumentException>(() => Source3.IsBalanced(open, close));
            Assert.Throws <ArgumentException>(() => Source3.IsBalanced(open, close, out unbalancedPosition));
        }