Skip to content

Commit

Permalink
Merge pull request #53 from dotarj/feature/backwards-compatibility-te…
Browse files Browse the repository at this point in the history
…sting

backwards compatibility testing
  • Loading branch information
dotarj authored Jan 24, 2019
2 parents 2e2a6a4 + 224c144 commit 6d14a24
Show file tree
Hide file tree
Showing 75 changed files with 3,119 additions and 6 deletions.
9 changes: 9 additions & 0 deletions protobuf-net-data.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "protobuf-net-data.Benchmarks", "benchmark\protobuf-net-data.Benchmarks\protobuf-net-data.Benchmarks.csproj", "{CC6192E6-16A5-47F4-ACAB-659D43C64C0C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{255B1CD0-4B1F-4601-9176-F36EE56CEF4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "protobuf-net-data.TestDataGenerator", "tools\protobuf-net-data.TestDataGenerator\protobuf-net-data.TestDataGenerator.csproj", "{4310BE9C-AACD-4071-8675-709E9929138B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -43,6 +47,10 @@ Global
{CC6192E6-16A5-47F4-ACAB-659D43C64C0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC6192E6-16A5-47F4-ACAB-659D43C64C0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC6192E6-16A5-47F4-ACAB-659D43C64C0C}.Release|Any CPU.Build.0 = Release|Any CPU
{4310BE9C-AACD-4071-8675-709E9929138B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4310BE9C-AACD-4071-8675-709E9929138B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4310BE9C-AACD-4071-8675-709E9929138B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4310BE9C-AACD-4071-8675-709E9929138B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -51,6 +59,7 @@ Global
{4F6074E7-D9B1-491D-841B-53A752EC1625} = {DE7CD50B-C28F-4FBB-B735-101C8AEA35FA}
{8CA91AF6-E972-4981-9A19-608D96D091B7} = {85F88385-53DB-4786-BFF7-1680292E667C}
{CC6192E6-16A5-47F4-ACAB-659D43C64C0C} = {5699EA47-126E-4C4F-A06A-B95D7AF4BA54}
{4310BE9C-AACD-4071-8675-709E9929138B} = {255B1CD0-4B1F-4601-9176-F36EE56CEF4D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {20DD757D-BEBB-4DFC-9F93-BDABCAAC3F29}
Expand Down
84 changes: 82 additions & 2 deletions test/protobuf-net-data.Tests/BackwardsCompatibilityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ public class BackwardsCompatibilityTests

private const string TestFile = "BackwardsCompatbilityTest.bin";

[Fact(Skip = "This test works locally, but not on AppVeyor. Temporarily disabled.")]
public void ShouldBeBackwardsCompatible()
{
var inputs = Directory.GetFiles("./backwards-compatibility", "*.proto");

foreach (var input in inputs)
{
var pathWithoutExtension = input.Substring(0, input.Length - 6);

var xmlDataSet = this.LoadXmlDataSet(pathWithoutExtension + ".xml", pathWithoutExtension + ".xsd");
var protoDataSet = this.LoadProtoDataSet(input);

this.ValidateTables(xmlDataSet, protoDataSet);
}
}

private static DataSet CreateTablesForBackwardsCompatibilityTest()
{
var tableA = new DataTable("A");
Expand Down Expand Up @@ -54,6 +70,71 @@ private static DataSet CreateTablesForBackwardsCompatibilityTest()
return dataSet;
}

private DataSet LoadXmlDataSet(string path, string schemaPath)
{
var xmlDataSet = new DataSet();

xmlDataSet.ReadXmlSchema(schemaPath);
xmlDataSet.ReadXml(path);

return xmlDataSet;
}

private DataSet LoadProtoDataSet(string path)
{
var protoDataSet = new DataSet();

using (var inputFile = File.OpenRead(path))
{
var inputDataReader = DataSerializer.Deserialize(inputFile);

protoDataSet.Load(inputDataReader, LoadOption.OverwriteChanges, "Table1", "Table2");
}

return protoDataSet;
}

private void ValidateTables(DataSet xmlDataSet, DataSet protoDataSet)
{
Assert.Equal(xmlDataSet.Tables.Count, protoDataSet.Tables.Count);

for (var tableIndex = 0; tableIndex < xmlDataSet.Tables.Count; tableIndex++)
{
var xmlDataTable = xmlDataSet.Tables[tableIndex];
var protoDataTable = protoDataSet.Tables[tableIndex];

this.ValidateColumns(xmlDataTable, protoDataTable);
this.ValidateRows(xmlDataTable, protoDataTable);
}
}

private void ValidateColumns(DataTable xmlDataTable, DataTable protoDataTable)
{
Assert.Equal(xmlDataTable.Columns.Count, protoDataTable.Columns.Count);

for (var columnIndex = 0; columnIndex < xmlDataTable.Columns.Count; columnIndex++)
{
var xmlDataColumn = xmlDataTable.Columns[columnIndex];
var protoDataColumn = protoDataTable.Columns[columnIndex];

Assert.Equal(xmlDataColumn.ColumnName, protoDataColumn.ColumnName);
Assert.Equal(xmlDataColumn.DataType, protoDataColumn.DataType);
}
}

private void ValidateRows(DataTable xmlDataTable, DataTable protoDataTable)
{
Assert.Equal(xmlDataTable.Rows.Count, protoDataTable.Rows.Count);

for (var rowIndex = 0; rowIndex < xmlDataTable.Rows.Count; rowIndex++)
{
var xmlDataRow = xmlDataTable.Rows[rowIndex];
var protoDataRow = protoDataTable.Rows[rowIndex];

Assert.Equal(xmlDataRow.ItemArray, protoDataRow.ItemArray);
}
}

public class When_reading
{
[Fact]
Expand Down Expand Up @@ -118,8 +199,7 @@ public void Should_retain_binary_compatibility_with_previous_versions_when_writi
}
}

// [Ignore("Only when our binary format changes (and we don't care about breaking old versions).")]
[Fact]
[Fact(Skip = "Only when our binary format changes (and we don't care about breaking old versions).")]
private void RegenerateTestFile()
{
using (DataSet dataSet = CreateTablesForBackwardsCompatibilityTest())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using ProtoBuf.Data;
using Xunit;

namespace ProtoBug.Data.Tests
namespace ProtoBuf.Data.Tests
{
public partial class DataSerializerEngineTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using ProtoBuf.Data;
using Xunit;

namespace ProtoBug.Data.Tests
namespace ProtoBuf.Data.Tests
{
public partial class DataSerializerEngineTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using ProtoBuf.Data;
using Xunit;

namespace ProtoBug.Data.Tests
namespace ProtoBuf.Data.Tests
{
public partial class DataSerializerEngineTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using ProtoBuf.Data;
using Xunit;

namespace ProtoBug.Data.Tests
namespace ProtoBuf.Data.Tests
{
public partial class DataSerializerEngineTests
{
Expand Down
Binary file not shown.
54 changes: 54 additions & 0 deletions test/protobuf-net-data.Tests/backwards-compatibility/2.0.0.452.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<NewDataSet>
<Table1>
<Table1_Column1>false</Table1_Column1>
<Table1_Column2>0</Table1_Column2>
<Table1_Column5>0001-01-01T00:00:00+01:00</Table1_Column5>
<Table1_Column6>0</Table1_Column6>
<Table1_Column7>00000000-0000-0000-0000-000000000000</Table1_Column7>
<Table1_Column8>0</Table1_Column8>
<Table1_Column9>0</Table1_Column9>
<Table1_Column10>0</Table1_Column10>
</Table1>
<Table1>
<Table1_Column1>false</Table1_Column1>
<Table1_Column2>62</Table1_Column2>
<Table1_Column3>7jw=</Table1_Column3>
<Table1_Column4 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<char>70</char>
<char>74</char>
</Table1_Column4>
<Table1_Column5>2018-05-17T19:48:50.9735228+02:00</Table1_Column5>
<Table1_Column6>0.717191357499543</Table1_Column6>
<Table1_Column7>f22ebfd0-265c-47e0-878a-821bccfda09d</Table1_Column7>
<Table1_Column8>68445533</Table1_Column8>
<Table1_Column9>1206514277</Table1_Column9>
<Table1_Column10>31938</Table1_Column10>
<Table1_Column11>EB</Table1_Column11>
</Table1>
<Table2>
<Table2_Column1>false</Table2_Column1>
<Table2_Column2>0</Table2_Column2>
<Table2_Column5>0001-01-01T00:00:00+01:00</Table2_Column5>
<Table2_Column6>0</Table2_Column6>
<Table2_Column7>00000000-0000-0000-0000-000000000000</Table2_Column7>
<Table2_Column8>0</Table2_Column8>
<Table2_Column9>0</Table2_Column9>
<Table2_Column10>0</Table2_Column10>
</Table2>
<Table2>
<Table2_Column1>false</Table2_Column1>
<Table2_Column2>152</Table2_Column2>
<Table2_Column3>ZsA=</Table2_Column3>
<Table2_Column4 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<char>71</char>
<char>88</char>
</Table2_Column4>
<Table2_Column5>2018-05-17T19:52:09.4164828+02:00</Table2_Column5>
<Table2_Column6>0.816669395108088</Table2_Column6>
<Table2_Column7>89d07285-f71b-499c-8220-bddb86e51f2b</Table2_Column7>
<Table2_Column8>278753461</Table2_Column8>
<Table2_Column9>281199730</Table2_Column9>
<Table2_Column10>12041</Table2_Column10>
<Table2_Column11>QI</Table2_Column11>
</Table2>
</NewDataSet>
43 changes: 43 additions & 0 deletions test/protobuf-net-data.Tests/backwards-compatibility/2.0.0.452.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element name="Table1_Column1" type="xs:boolean" minOccurs="0" />
<xs:element name="Table1_Column2" type="xs:unsignedByte" minOccurs="0" />
<xs:element name="Table1_Column3" type="xs:base64Binary" minOccurs="0" />
<xs:element name="Table1_Column4" msdata:DataType="System.Char[]" type="xs:anyType" minOccurs="0" />
<xs:element name="Table1_Column5" type="xs:dateTime" minOccurs="0" />
<xs:element name="Table1_Column6" type="xs:decimal" minOccurs="0" />
<xs:element name="Table1_Column7" msdata:DataType="System.Guid" type="xs:string" minOccurs="0" />
<xs:element name="Table1_Column8" type="xs:int" minOccurs="0" />
<xs:element name="Table1_Column9" type="xs:long" minOccurs="0" />
<xs:element name="Table1_Column10" type="xs:short" minOccurs="0" />
<xs:element name="Table1_Column11" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table2">
<xs:complexType>
<xs:sequence>
<xs:element name="Table2_Column1" type="xs:boolean" minOccurs="0" />
<xs:element name="Table2_Column2" type="xs:unsignedByte" minOccurs="0" />
<xs:element name="Table2_Column3" type="xs:base64Binary" minOccurs="0" />
<xs:element name="Table2_Column4" msdata:DataType="System.Char[]" type="xs:anyType" minOccurs="0" />
<xs:element name="Table2_Column5" type="xs:dateTime" minOccurs="0" />
<xs:element name="Table2_Column6" type="xs:decimal" minOccurs="0" />
<xs:element name="Table2_Column7" msdata:DataType="System.Guid" type="xs:string" minOccurs="0" />
<xs:element name="Table2_Column8" type="xs:int" minOccurs="0" />
<xs:element name="Table2_Column9" type="xs:long" minOccurs="0" />
<xs:element name="Table2_Column10" type="xs:short" minOccurs="0" />
<xs:element name="Table2_Column11" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Binary file not shown.
54 changes: 54 additions & 0 deletions test/protobuf-net-data.Tests/backwards-compatibility/2.0.1.470.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<NewDataSet>
<Table1>
<Table1_Column1>false</Table1_Column1>
<Table1_Column2>0</Table1_Column2>
<Table1_Column5>0001-01-01T00:00:00+01:00</Table1_Column5>
<Table1_Column6>0</Table1_Column6>
<Table1_Column7>00000000-0000-0000-0000-000000000000</Table1_Column7>
<Table1_Column8>0</Table1_Column8>
<Table1_Column9>0</Table1_Column9>
<Table1_Column10>0</Table1_Column10>
</Table1>
<Table1>
<Table1_Column1>false</Table1_Column1>
<Table1_Column2>147</Table1_Column2>
<Table1_Column3>+M4=</Table1_Column3>
<Table1_Column4 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<char>73</char>
<char>71</char>
</Table1_Column4>
<Table1_Column5>2018-05-17T19:51:05.7678962+02:00</Table1_Column5>
<Table1_Column6>0.0518967486228313</Table1_Column6>
<Table1_Column7>4488f503-719d-4f7b-8731-99e90a1bcb6d</Table1_Column7>
<Table1_Column8>1229012294</Table1_Column8>
<Table1_Column9>281072339</Table1_Column9>
<Table1_Column10>21425</Table1_Column10>
<Table1_Column11>BC</Table1_Column11>
</Table1>
<Table2>
<Table2_Column1>false</Table2_Column1>
<Table2_Column2>0</Table2_Column2>
<Table2_Column5>0001-01-01T00:00:00+01:00</Table2_Column5>
<Table2_Column6>0</Table2_Column6>
<Table2_Column7>00000000-0000-0000-0000-000000000000</Table2_Column7>
<Table2_Column8>0</Table2_Column8>
<Table2_Column9>0</Table2_Column9>
<Table2_Column10>0</Table2_Column10>
</Table2>
<Table2>
<Table2_Column1>false</Table2_Column1>
<Table2_Column2>138</Table2_Column2>
<Table2_Column3>QGE=</Table2_Column3>
<Table2_Column4 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<char>88</char>
<char>78</char>
</Table2_Column4>
<Table2_Column5>2018-05-17T19:48:39.1405956+02:00</Table2_Column5>
<Table2_Column6>0.0665076417226846</Table2_Column6>
<Table2_Column7>f0076c18-fed1-4e2d-8f1c-16d1ddf15ba2</Table2_Column7>
<Table2_Column8>416588243</Table2_Column8>
<Table2_Column9>538253825</Table2_Column9>
<Table2_Column10>31334</Table2_Column10>
<Table2_Column11>TK</Table2_Column11>
</Table2>
</NewDataSet>
43 changes: 43 additions & 0 deletions test/protobuf-net-data.Tests/backwards-compatibility/2.0.1.470.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element name="Table1_Column1" type="xs:boolean" minOccurs="0" />
<xs:element name="Table1_Column2" type="xs:unsignedByte" minOccurs="0" />
<xs:element name="Table1_Column3" type="xs:base64Binary" minOccurs="0" />
<xs:element name="Table1_Column4" msdata:DataType="System.Char[]" type="xs:anyType" minOccurs="0" />
<xs:element name="Table1_Column5" type="xs:dateTime" minOccurs="0" />
<xs:element name="Table1_Column6" type="xs:decimal" minOccurs="0" />
<xs:element name="Table1_Column7" msdata:DataType="System.Guid" type="xs:string" minOccurs="0" />
<xs:element name="Table1_Column8" type="xs:int" minOccurs="0" />
<xs:element name="Table1_Column9" type="xs:long" minOccurs="0" />
<xs:element name="Table1_Column10" type="xs:short" minOccurs="0" />
<xs:element name="Table1_Column11" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table2">
<xs:complexType>
<xs:sequence>
<xs:element name="Table2_Column1" type="xs:boolean" minOccurs="0" />
<xs:element name="Table2_Column2" type="xs:unsignedByte" minOccurs="0" />
<xs:element name="Table2_Column3" type="xs:base64Binary" minOccurs="0" />
<xs:element name="Table2_Column4" msdata:DataType="System.Char[]" type="xs:anyType" minOccurs="0" />
<xs:element name="Table2_Column5" type="xs:dateTime" minOccurs="0" />
<xs:element name="Table2_Column6" type="xs:decimal" minOccurs="0" />
<xs:element name="Table2_Column7" msdata:DataType="System.Guid" type="xs:string" minOccurs="0" />
<xs:element name="Table2_Column8" type="xs:int" minOccurs="0" />
<xs:element name="Table2_Column9" type="xs:long" minOccurs="0" />
<xs:element name="Table2_Column10" type="xs:short" minOccurs="0" />
<xs:element name="Table2_Column11" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Binary file not shown.
Loading

0 comments on commit 6d14a24

Please sign in to comment.