Example #1
0
            public When_a_table_with_no_rows_is_immediately_followed_by_a_non_empty_one()
            {
                this.dataSet = new DataSet();

                var tableWithNoRows = new DataTable();

                tableWithNoRows.Columns.Add("Something", typeof(DateTime));
                var c = new[]
                {
                    new object[] { "Number", "Letter" },
                    new object[] { 9, "Z" },
                    new object[] { 8, "Y" }
                };

                this.dataSet.Tables.Add(tableWithNoRows);
                this.dataSet.Tables.Add(TestData.FromMatrix(c));

                this.stream = new MemoryStream();
                using (var originalReader = this.dataSet.CreateDataReader())
                {
                    DataSerializer.Serialize(this.stream, originalReader);

                    this.stream.Seek(0, SeekOrigin.Begin);

                    this.reader = DataSerializer.Deserialize(this.stream);
                }
            }
Example #2
0
            public void Should_not_throw_any_exception()
            {
                // Fix for issue #12 https://github.com/rdingwall/protobuf-net-data/issues/12
                var matrix = new[]
                {
                    new object[] { "A", "B" },
                    new object[] { 1, 2 },
                    new object[] { 10, 20 },
                };

                using (var table = TestData.FromMatrix(matrix))
                    using (var reader = table.CreateDataReader())
                        using (var schemaTable = reader.GetSchemaTable())
                        {
                            var moqReader = new Mock <IDataReader>();
                            moqReader.Setup(r => r.GetSchemaTable()).Returns(schemaTable).Verifiable();
                            var originalReader = moqReader.Object;
                            schemaTable.Columns.Remove("Expression");

                            using (var stream = Stream.Null)
                            {
                                new ProtoDataWriter().Serialize(stream, originalReader);
                            }

                            moqReader.Verify();
                        }
            }
Example #3
0
            public void TestFixtureSetUp()
            {
                dataSet = new DataSet();

                var tableWithNoRows = new DataTable();

                tableWithNoRows.Columns.Add("Something", typeof(DateTime));
                var c = new[]
                {
                    new object[] { "Number", "Letter" },
                    new object[] { 9, "Z" },
                    new object[] { 8, "Y" }
                };

                dataSet.Tables.Add(tableWithNoRows);
                dataSet.Tables.Add(TestData.FromMatrix(c));

                stream = new MemoryStream();
                using (var originalReader = dataSet.CreateDataReader())
                {
                    DataSerializer.Serialize(stream, originalReader);

                    stream.Seek(0, SeekOrigin.Begin);

                    reader = DataSerializer.Deserialize(stream);
                }
            }
Example #4
0
            public When_advancing_to_the_next_result_set_but_still_in_the_middle_of_the_current_one()
            {
                var a = new[]
                {
                    new object[] { "Number" },
                    new object[] { 0 },
                    new object[] { 1 },
                    new object[] { 2 },
                    new object[] { 3 },
                    new object[] { 4 },
                    new object[] { 5 },
                    new object[] { 6 },
                    new object[] { 7 },
                    new object[] { 8 },
                    new object[] { 9 },
                };

                var b = new[]
                {
                    new object[] { "Letter", "Number" },
                    new object[] { "A", 9 },
                    new object[] { "B", 8 },
                    new object[] { "C", 7 },
                    new object[] { "D", 6 },
                    new object[] { "E", 5 },
                };

                this.dataSet = new DataSet();

                var tableWithNoRows = new DataTable();

                tableWithNoRows.Columns.Add("ColumnA", typeof(Guid));

                var c = new[]
                {
                    new object[] { "Number" },
                    new object[] { 9 },
                    new object[] { 8 }
                };

                this.dataSet.Tables.Add(TestData.FromMatrix(a));
                this.dataSet.Tables.Add(TestData.FromMatrix(b));
                this.dataSet.Tables.Add(tableWithNoRows);
                this.dataSet.Tables.Add(new DataTable());
                this.dataSet.Tables.Add(TestData.FromMatrix(c));

                this.stream = new MemoryStream();
                using (var originalReader = this.dataSet.CreateDataReader())
                {
                    DataSerializer.Serialize(this.stream, originalReader);

                    this.stream.Seek(0, SeekOrigin.Begin);

                    this.reader = DataSerializer.Deserialize(this.stream);
                }
            }
Example #5
0
            public void TestFixtureSetUp()
            {
                var a = new[]
                {
                    new object[] { "Number" },
                    new object[] { 0 },
                    new object[] { 1 },
                    new object[] { 2 },
                    new object[] { 3 },
                    new object[] { 4 },
                    new object[] { 5 },
                    new object[] { 6 },
                    new object[] { 7 },
                    new object[] { 8 },
                    new object[] { 9 },
                };

                var b = new[]
                {
                    new object[] { "Letter", "Number" },
                    new object[] { "A", 9 },
                    new object[] { "B", 8 },
                    new object[] { "C", 7 },
                    new object[] { "D", 6 },
                    new object[] { "E", 5 },
                };

                dataSet = new DataSet();

                var tableWithNoRows = new DataTable();

                tableWithNoRows.Columns.Add("ColumnA", typeof(Guid));

                var c = new[]
                {
                    new object[] { "Number" },
                    new object[] { 9 },
                    new object[] { 8 }
                };

                dataSet.Tables.Add(TestData.FromMatrix(a));
                dataSet.Tables.Add(TestData.FromMatrix(b));
                dataSet.Tables.Add(tableWithNoRows);
                dataSet.Tables.Add(new DataTable());
                dataSet.Tables.Add(TestData.FromMatrix(c));

                stream = new MemoryStream();
                using (var originalReader = dataSet.CreateDataReader())
                {
                    DataSerializer.Serialize(stream, originalReader);

                    stream.Seek(0, SeekOrigin.Begin);

                    reader = DataSerializer.Deserialize(stream);
                }
            }
            public void TestFixtureSetUp()
            {
                var matrix = new[]
                {
                    new object[] { "A", "B" },
                    new object[] { new byte[] {}, "X" },
                    new object[] { null, "Y" },
                };

                originalTable = TestData.FromMatrix(matrix);

                deserializedTable = TestHelper.SerializeAndDeserialize(originalTable);
            }
Example #7
0
            public When_serializing_a_data_table_with_zero_length_arrays()
            {
                var matrix = new[]
                {
                    new object[] { "A", "B" },
                    new object[] { new byte[0], "X" },
                    new object[] { null, "Y" },
                };

                this.originalTable = TestData.FromMatrix(matrix);

                this.deserializedTable = TestHelper.SerializeAndDeserialize(this.originalTable);
            }
Example #8
0
            public When_serializing_a_data_table_including_computed_columns()
            {
                var matrix = new[]
                {
                    new object[] { "A", "B" },
                    new object[] { 1, 2 },
                    new object[] { 10, 20 },
                };

                this.originalTable = TestData.FromMatrix(matrix);
                this.originalTable.Columns.Add(new DataColumn("C", typeof(int), "A+B"));

                this.deserializedTable = TestHelper.SerializeAndDeserialize(this.originalTable, new ProtoDataWriterOptions {
                    IncludeComputedColumns = true
                });
            }
            public void TestFixtureSetUp()
            {
                var matrix = new[]
                {
                    new object[] { "A", "B" },
                    new object[] { 1, 2 },
                    new object[] { 10, 20 },
                };

                originalTable = TestData.FromMatrix(matrix);
                originalTable.Columns.Add(new DataColumn("C", typeof(int), "A+B"));

                deserializedTable = TestHelper.SerializeAndDeserialize(originalTable,
                                                                       new ProtoDataWriterOptions {
                    IncludeComputedColumns = true
                });
            }
            public void TestFixtureSetUp()
            {
                var matrix = new[]
                {
                    new object[] { "A", "B" },
                    new object[] { 1, 2 },
                    new object[] { 10, 20 },
                };

                originalTable = TestData.FromMatrix(matrix);

                var computed = TestData.FromMatrix(matrix);

                computed.Columns.Add(new DataColumn("C", typeof(int), "A+B"));

                deserializedTable = TestHelper.SerializeAndDeserialize(computed);
            }
Example #11
0
            public When_serializing_a_data_table_with_a_computed_column()
            {
                var matrix = new[]
                {
                    new object[] { "A", "B" },
                    new object[] { 1, 2 },
                    new object[] { 10, 20 },
                };

                this.originalTable = TestData.FromMatrix(matrix);

                var computed = TestData.FromMatrix(matrix);

                computed.Columns.Add(new DataColumn("C", typeof(int), "A+B"));

                this.deserializedTable = TestHelper.SerializeAndDeserialize(computed);
            }