public void ShouldNotSerializeExpressionColumn()
            {
                var isRunningOnMono = Type.GetType("Mono.Runtime") != null;

                if (!isRunningOnMono)
                {
                    // Arrange
                    var columnName = "foo";
                    var dataTable  = new DataTable();

                    dataTable.Columns.Add(columnName, typeof(int));

                    dataTable.Rows.Add(1);

                    var dataReader = dataTable.CreateDataReader();

                    dataReader.GetSchemaTable().Rows[0]["Expression"] = true;

                    var options = new ProtoDataWriterOptions()
                    {
                        IncludeComputedColumns = false
                    };

                    // Act
                    var reader = new ProtoReader(this.Serialize(dataReader, options), null, null);

                    // Assert
                    var readerContext = new ProtoReaderContext(reader);

                    readerContext.ReadExpectedFieldHeader(ResultFieldHeader);
                    readerContext.StartSubItem();

                    Assert.Equal(RecordFieldHeader, reader.ReadFieldHeader());
                }
            }
Пример #2
0
            public void ShouldNotSerializeIfValueIsNull()
            {
                // Arrange
                string value      = null;
                var    dataReader = this.CreateDataReader(value);

                // Act
                var reader = new ProtoReader(this.Serialize(dataReader), null, null);

                // Assert
                var readerContext = new ProtoReaderContext(reader);

                readerContext.ReadUntilField();
                readerContext.ReadExpectedFieldHeader(3);

                Assert.Equal(0, reader.ReadFieldHeader());
            }
Пример #3
0
            public void ShouldNotSerializeIfValueIsEmptyArray()
            {
                // Arrange
                var value      = new char[0];
                var dataReader = this.CreateDataReader(value);

                var options = new ProtoDataWriterOptions()
                {
                    SerializeEmptyArraysAsNull = true
                };

                // Act
                var reader = new ProtoReader(this.Serialize(dataReader, options), null, null);

                // Assert
                var readerContext = new ProtoReaderContext(reader);

                readerContext.ReadUntilField();
                readerContext.ReadExpectedFieldHeader(3);

                Assert.Equal(0, reader.ReadFieldHeader());
            }
Пример #4
0
            public void ShouldSerializeEmptyCharArrayAsNull()
            {
                // Arrange
                var dataReader = this.CreateDataReader(new char[0]);
                var options    = new ProtoDataWriterOptions()
                {
                    SerializeEmptyArraysAsNull = true
                };

                // Act
                var reader = new ProtoReader(this.Serialize(dataReader, options), null, null);

                // Assert
                var readerContext = new ProtoReaderContext(reader);

                readerContext.ReadUntilField();

                readerContext.ReadExpectedFieldHeader(3);
                readerContext.StartSubItem();

                Assert.Equal(0, reader.ReadFieldHeader());
            }
Пример #5
0
            public void ShouldNotSerializeIfValueIsDBNull()
            {
                // Arrange
                var value     = DBNull.Value;
                var dataTable = new DataTable();

                dataTable.Columns.Add("foo", typeof(string));

                dataTable.Rows.Add(value);

                var dataReader = dataTable.CreateDataReader();

                // Act
                var reader = new ProtoReader(this.Serialize(dataReader), null, null);

                // Assert
                var readerContext = new ProtoReaderContext(reader);

                readerContext.ReadUntilField();
                readerContext.ReadExpectedFieldHeader(3);

                Assert.Equal(0, reader.ReadFieldHeader());
            }