public void ShouldSerializeMultipleResults()
        {
            // Arrange
            var dataSet = new DataSet();

            dataSet.Tables.Add(new DataTable());
            dataSet.Tables.Add(new DataTable());

            dataSet.Tables[0].Columns.Add("foo", typeof(int));
            dataSet.Tables[0].Rows.Add(1);

            dataSet.Tables[1].Columns.Add("bar", typeof(int));
            dataSet.Tables[1].Rows.Add(1);

            var dataReader = dataSet.CreateDataReader();

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

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

            readerContext.ReadUntilResultEnd();

            Assert.Equal(ResultFieldHeader, reader.ReadFieldHeader());
        }
Exemplo n.º 2
0
            public void ShouldSerializeSuccessiveResultColumns()
            {
                // Arrange
                var dataSet = new DataSet();

                dataSet.Tables.Add(new DataTable());
                dataSet.Tables.Add(new DataTable());

                dataSet.Tables[0].Columns.Add("foo", typeof(int));
                dataSet.Tables[0].Rows.Add(1);

                var columnName = "bar";

                dataSet.Tables[1].Columns.Add(columnName, typeof(int));
                dataSet.Tables[1].Rows.Add(1);

                var dataReader = dataSet.CreateDataReader();

                var stream = new ProtoDataStream(dataReader);

                // Act
                var reader = ProtoReader.Create(this.CopyStream(stream), null, null);

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

                readerContext.ReadUntilResultEnd();
                readerContext.ReadUntilColumnName();

                Assert.Equal(columnName, reader.ReadString());
            }