Exemple #1
0
 public void AppendOverCountWithIndexThrows()
 {
     using (var buffer = new StringBuffer())
     {
         Action action = () => buffer.Append("A", startIndex: 1, count: 1);
         action.ShouldThrow<ArgumentOutOfRangeException>();
     }
 }
Exemple #2
0
 public void AppendNegativeIndexThrows()
 {
     using (var buffer = new StringBuffer())
     {
         Action action = () => buffer.Append("a", startIndex: -1);
         action.ShouldThrow<ArgumentOutOfRangeException>();
     }
 }
Exemple #3
0
 public void AppendNullStringBufferThrows()
 {
     using (var buffer = new StringBuffer())
     {
         Action action = () => buffer.Append((StringBuffer)null);
         action.ShouldThrow<ArgumentNullException>();
     }
 }
Exemple #4
0
        public void AppendTests(string source, string value, int startIndex, int count, string expected)
        {
            // From string
            using (var buffer = new StringBuffer(source))
            {
                buffer.Append(value, startIndex, count);
                buffer.ToString().Should().Be(expected);
            }

            // From buffer
            using (var buffer = new StringBuffer(source))
            using (var valueBuffer = new StringBuffer(value))
            {
                if (count == -1)
                    buffer.Append(valueBuffer, (ulong)startIndex);
                else
                    buffer.Append(valueBuffer, (ulong)startIndex, (ulong)count);
                buffer.ToString().Should().Be(expected);
            }
        }
Exemple #5
0
        public void SubStringIndexPlusCountCombinedOutOfRangeThrows()
        {
            using (var buffer = new StringBuffer("a"))
            {
                Action action = () => buffer.SubString(startIndex: 1, count: 1);
                action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("startIndex");

                buffer.Append("b");
                action.ShouldNotThrow<ArgumentOutOfRangeException>();

                action = () => buffer.SubString(startIndex: 1, count: 2);
                action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("count");
            }
        }
Exemple #6
0
        public void SubStringIndexOverLengthThrows()
        {
            using (var buffer = new StringBuffer())
            {
                Action action = () => buffer.SubString(startIndex: 1);
                action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("startIndex");

                buffer.Append("a");
                action.ShouldThrow<ArgumentOutOfRangeException>().And.ParamName.Should().Be("startIndex");

                buffer.Append("b");
                action.ShouldNotThrow();
            }
        }