Exemple #1
0
            /// <summary>
            /// Verifies the result of executing the test action.
            /// </summary>
            /// <param name="readDescriptor">The descriptors of the read operations to be executed against the stream.</param>
            /// <param name="buffer">The byte buffer with the bytes read.</param>
            /// <param name="actualNumberOfBytesRead">The actual numbers of bytes read.</param>
            /// <param name="line">The line read from the stream.</param>
            protected void VerifyResult(
                BatchReaderStreamReadDescriptor readDescriptor,
                byte[] buffer,
                int actualNumberOfBytesRead)
            {
                // Check that we read the expected number of bytes
                this.Assert.AreEqual(readDescriptor.ExpectedNumberOfBytesRead, actualNumberOfBytesRead,
                                     string.Format("\r\n{0}:\r\nExpected to read '{1}' bytes but the actual number of bytes read is '{2}'.", this.DebugDescription, readDescriptor.ExpectedNumberOfBytesRead, actualNumberOfBytesRead));

                // Now make sure the bytes we read are correct
                this.Assert.IsNotNull(this.payloadStream, "Must have a payload stream.");
                byte[] sourceBytes = this.payloadStream.GetBuffer();

                for (int i = 0; i < readDescriptor.ExpectedNumberOfBytesRead; ++i)
                {
                    this.Assert.AreEqual(sourceBytes[readDescriptor.SourceStreamOffset + i], buffer[readDescriptor.BufferOffset + i],
                                         string.Format("\r\n{0}:\r\nExpected to find '{1}' at position '{2}' but the actual value is '{3}'.",
                                                       this.DebugDescription,
                                                       sourceBytes[readDescriptor.SourceStreamOffset + i],
                                                       i,
                                                       buffer[i]));
                }
            }
            /// <summary>
            /// Verifies the result of executing the test action.
            /// </summary>
            /// <param name="readDescriptor">The descriptors of the read operations to be executed against the stream.</param>
            /// <param name="buffer">The byte buffer with the bytes read.</param>
            /// <param name="actualNumberOfBytesRead">The actual numbers of bytes read.</param>
            /// <param name="line">The line read from the stream.</param>
            protected void VerifyResult(
                BatchReaderStreamReadDescriptor readDescriptor, 
                byte[] buffer, 
                int actualNumberOfBytesRead)
            {
                // Check that we read the expected number of bytes
                this.Assert.AreEqual(readDescriptor.ExpectedNumberOfBytesRead, actualNumberOfBytesRead,
                    string.Format("\r\n{0}:\r\nExpected to read '{1}' bytes but the actual number of bytes read is '{2}'.", this.DebugDescription, readDescriptor.ExpectedNumberOfBytesRead, actualNumberOfBytesRead));

                // Now make sure the bytes we read are correct
                this.Assert.IsNotNull(this.payloadStream, "Must have a payload stream.");
                byte[] sourceBytes = this.payloadStream.GetBuffer();

                for (int i = 0; i < readDescriptor.ExpectedNumberOfBytesRead; ++i)
                {
                    this.Assert.AreEqual(sourceBytes[readDescriptor.SourceStreamOffset + i], buffer[readDescriptor.BufferOffset + i],
                        string.Format("\r\n{0}:\r\nExpected to find '{1}' at position '{2}' but the actual value is '{3}'.", 
                        this.DebugDescription, 
                        sourceBytes[readDescriptor.SourceStreamOffset + i],
                        i,
                        buffer[i]));
                }
            }