public void ShouldThrowExceptionWhenNoData()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: new[] { 'a' });

                // Assert
                Assert.Throws <InvalidOperationException>(() => dataReader.GetChars(0, 0, new char[1], 0, 1));
            }
            public void ShouldThrowExceptionWhenNoData()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: "foo");

                // Assert
                Assert.Throws <InvalidOperationException>(() => dataReader.GetValue(0));
            }
Beispiel #3
0
            public void ShouldThrowException()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: true);

                // Assert
                Assert.Throws <NotSupportedException>(() => ((IDataReader)dataReader).GetData(0));
            }
Beispiel #4
0
            public void ShouldThrowExceptionWhenDataReaderIsClosed()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: long.MinValue);

                // Assert
                Assert.Throws <InvalidOperationException>(() => dataReader.GetInt64(0));
            }
            public void ShouldThrowExceptionWhenDataReaderIsClosed()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: true);

                dataReader.Close();

                // Assert
                Assert.Throws <InvalidOperationException>(() => dataReader.Depth);
            }
Beispiel #6
0
            public void ShouldReturnFalseIfNotNull()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: "foo");

                dataReader.Read();

                // Assert
                Assert.False(dataReader.IsDBNull(0));
            }
Beispiel #7
0
            public void ShouldReturnTrueIfNull()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: (string)null);

                dataReader.Read();

                // Assert
                Assert.True(dataReader.IsDBNull(0));
            }
            public void ShouldThrowExceptionWhenByteArrayLengthAndBufferOffsetIsGreaterThanBufferLength()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: new[] { 'a', 'b' });

                dataReader.Read();

                // Assert
                Assert.Throws <IndexOutOfRangeException>(() => dataReader.GetChars(0, 0, new char[2], 1, 0));
            }
Beispiel #9
0
            public void ShouldThrowExceptionWhenValuesIsNull()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: "foo");

                dataReader.Close();

                // Assert
                Assert.Throws <ArgumentNullException>(() => dataReader.GetValues(null));
            }
            public void ShouldThrowExceptionWhenFieldOffsetIsLessThanZero()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: new[] { 'a' });

                dataReader.Read();

                // Assert
                Assert.Throws <InvalidOperationException>(() => dataReader.GetChars(0, -1, new char[1], 0, 1));
            }
            public void ShouldThrowExceptionWhenIndexIsOutOfRange()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: new[] { 'a' });

                dataReader.Read();

                // Assert
                Assert.Throws <IndexOutOfRangeException>(() => dataReader.GetChars(dataReader.FieldCount, 0, new char[0], 0, 1));
            }
            public void ShouldThrowExceptionWhenIsNull()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: (string)null);

                dataReader.Read();

                // Assert
                Assert.Throws <InvalidOperationException>(() => dataReader.GetChars(0, 0, new char[1], 0, 1));
            }
            public void ShouldThrowExceptionWhenBufferOffsetIsGreaterThanBufferSize()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: new[] { 'a' });

                dataReader.Read();

                // Assert
                Assert.Throws <ArgumentOutOfRangeException>(() => dataReader.GetChars(0, 0, new char[1], 10, 1));
            }
Beispiel #14
0
            public void ShouldNotCloseWhenNoMoreResults()
            {
                // Act
                var dataReader = DataReaderHelper.CreateDataReader(value: (string)null);

                dataReader.NextResult();

                // Assert
                Assert.False(dataReader.IsClosed);
            }
            public void ShouldThrowExceptionWhenIndexIsOutOfRange()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: "foo");

                dataReader.Read();

                // Assert
                Assert.Throws <IndexOutOfRangeException>(() => dataReader.GetValue(dataReader.FieldCount));
            }
            public void ShouldThrowExceptionWhenDataReaderIsClosed()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: "foo");

                dataReader.Close();

                // Assert
                Assert.Throws <InvalidOperationException>(() => dataReader.GetDataTypeName(0));
            }
            public void ShouldThrowExceptionWhenLengthIsLessThanZero()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: new[] { 'a' });

                dataReader.Read();

                // Assert
                Assert.Throws <IndexOutOfRangeException>(() => dataReader.GetChars(0, 0, new char[1], 0, -1));
            }
            public void ShouldSetTableName()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: "foo");

                // Act
                var schemaTable = dataReader.GetSchemaTable();

                // Assert
                Assert.Equal("SchemaTable", schemaTable.TableName);
            }
Beispiel #19
0
            public void ShouldReturnCorrespondingValue()
            {
                // Arrange
                var value      = long.MinValue;
                var dataReader = DataReaderHelper.CreateDataReader(value: value);

                dataReader.Read();

                // Assert
                Assert.Equal(value, dataReader.GetInt64(0));
            }
Beispiel #20
0
            public void ShouldReturnFalseWhenNoMoreResults()
            {
                // Act
                var dataReader = DataReaderHelper.CreateDataReader(value: (string)null);

                // Act
                var result = dataReader.NextResult();

                // Assert
                Assert.False(result);
            }
            public void ShouldReturnCorrespondingDataTypeName()
            {
                // Arrange
                var value      = "foo";
                var dataReader = DataReaderHelper.CreateDataReader(value: value);

                // Act
                var result = dataReader.GetDataTypeName(0);

                // Assert
                Assert.Equal(value.GetType().Name, result);
            }
            public void ShouldAdjustCopyLengthWhenFieldOffsetAndLengthExceedsByteArrayLength()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: new[] { 'a' });

                dataReader.Read();

                // Act
                var copyLength = dataReader.GetChars(0, 0, new char[1], 0, 2);

                // Assert
                Assert.Equal(1, copyLength);
            }
            public void ShouldReturnZeroWhenFieldOffsetIsGreaterThanByteArrayLength()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: new[] { 'a' });

                dataReader.Read();

                // Act
                var copyLength = dataReader.GetChars(0, 1, new char[1], 0, 1);

                // Assert
                Assert.Equal(0, copyLength);
            }
            public void ShouldReturnCorrespondingValue()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: true);

                dataReader.Read();

                // Act
                var result = dataReader.GetBoolean(0);

                // Assert
                Assert.True(result);
            }
            public void ShouldReturnZero()
            {
                // Arrange
                var dataReader = DataReaderHelper.CreateDataReader(value: true);

                dataReader.Read();

                // Act
                var result = dataReader.Depth;

                // Assert
                Assert.Equal(0, result);
            }
            public void ShouldReturnCorrespondingValue()
            {
                // Arrange
                var value      = (byte)0b0010_1010;
                var dataReader = DataReaderHelper.CreateDataReader(value: value);

                dataReader.Read();

                // Act
                var result = dataReader.GetByte(0);

                // Assert
                Assert.Equal(value, result);
            }
            public void ShouldReturnCorrespondingValue()
            {
                // Arrange
                var value      = DateTime.Now;
                var dataReader = DataReaderHelper.CreateDataReader(value: value);

                dataReader.Read();

                // Act
                var result = dataReader.GetDateTime(0);

                // Assert
                Assert.Equal(value, result);
            }
            public void ShouldReturnCorrespondingValue()
            {
                // Arrange
                var value      = "foo";
                var dataReader = DataReaderHelper.CreateDataReader(value: value);

                dataReader.Read();

                // Act
                var result = dataReader.GetValue(0);

                // Assert
                Assert.Equal(value, Convert.ToString(result));
            }
            public void ShouldReturnByteArrayLengthWhenBufferIsNull()
            {
                // Arrange
                var value      = new[] { 'a' };
                var dataReader = DataReaderHelper.CreateDataReader(value: value);

                dataReader.Read();

                // Act
                var result = dataReader.GetChars(0, 0, null, 0, 1);

                // Assert
                Assert.Equal(value.Length, result);
            }
            public void ShouldReturnCorrespondingValue()
            {
                // Arrange
                var value      = new[] { 'a' };
                var dataReader = DataReaderHelper.CreateDataReader(value: value);

                dataReader.Read();

                var buffer = new char[1];

                // Act
                var copyLength = dataReader.GetChars(0, 0, buffer, 0, 1);

                // Assert
                Assert.Equal(value, buffer);
            }