Exemplo n.º 1
0
        public void CanWriteXmlToStream()
        {
            DataSet      dataSet    = new DataSetBuilder().CreateAndBuildDefaultDbSet(_dataSetName);
            MemoryStream memStream  = new MemoryStream();
            var          mockLogger = Mock.Of <IAppLogger <DataSetStreamXmlReaderWriter> >();


            IDataSetStreamWriter writer = new DataSetStreamXmlReaderWriter(mockLogger);

            writer.Write(dataSet, memStream);

            Assert.True(memStream.Length > 0);
            memStream.Dispose();
        }
Exemplo n.º 2
0
        public void CanReadXmlFromStream()
        {
            DataSet      dataSet    = new DataSetBuilder().CreateAndBuildDefaultDbSet(_dataSetName);
            MemoryStream memStream  = new MemoryStream();
            var          mockLogger = Mock.Of <IAppLogger <DataSetStreamXmlReaderWriter> >();

            IDataSetStreamWriter writer = new DataSetStreamXmlReaderWriter(mockLogger);

            writer.Write(dataSet, memStream);

            memStream.Seek(0, SeekOrigin.Begin);

            IDataSetStreamReader reader = new DataSetStreamXmlReaderWriter(mockLogger);
            var ds = reader.Read <DataSet>(memStream);

            Assert.Equal(_dataSetName, ds.DataSetName);
            Assert.Equal(DataSetBuilder.DefaultDataSetTablesCount, ds.Tables.Count);
            Assert.Equal(DataSetBuilder.DefaultCatalogRowsCount, dataSet.Tables[DataSetBuilder.CatalogTableName].Rows.Count);

            memStream.Dispose();
        }