Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wasm] Enable System.Data.Common tests #39463

Merged
merged 6 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System
{
public static class SuitePlatformDetection
{
//
// Do not use the " { get; } = <expression> " pattern here. Having all the initialization happen in the type initializer
// means that one exception anywhere means all tests using PlatformDetection fail. If you feel a value is worth latching,
// do it in a way that failures don't cascade.
//
public static bool IsBinaryFormatterSupportedAndNotInvariantGlobalization => PlatformDetection.IsBinaryFormatterSupported && PlatformDetection.IsNotInvariantGlobalization;
steveisok marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<Compile Include="System\Data\SqlTypes\SqlStringTest.cs" />
<Compile Include="System\Data\SqlTypes\SqlStringSortingTest.cs" />
<Compile Include="System\Data\SqlTypes\SqlXmlTest.cs" />
<Compile Include="SuitePlatformDetection.cs" />
<Compile Include="System\Data\SyntaxErrorExceptionTest.cs" />
<Compile Include="System\Data\TrailingSpaceTest.cs" />
<Compile Include="System\Data\UniqueConstraintTest.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public sealed class TestProviderFactory : DbProviderFactory
private TestProviderFactory() { }
}

[PlatformSpecific(~TestPlatforms.Browser)]
public class DbProviderFactoriesTests
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace System.Data.Tests.Common
{
[PlatformSpecific(~TestPlatforms.Browser)]
public class DbProviderFactoryTest
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ public void IsNull_ByIndex()
Assert.True(dr.IsNull(1));
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void IsNull_ByName()
{
DataTable dt = new DataTable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public void SimpleElementTable()
DataSetAssertion.AssertDataColumn("col3", dt.Columns[2], "col3", true, false, 0, 1, "col3", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 2, string.Empty, false, false);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void SimpleDataSet()
{
DataSet ds = GetDataSet(_xml8, null);
Expand Down Expand Up @@ -337,7 +337,7 @@ public void SignificantWhitespaceIgnored2()
DataSetAssertion.AssertDataSet("pure_whitespace", ds, "root", 0, 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void TwoElementTable()
{
// FIXME: Also test ReadXml (, XmlReadMode.InferSchema) and
Expand All @@ -356,7 +356,7 @@ public void TwoElementTable()
DataSetAssertion.AssertDataColumn("col2_2", dt.Columns[1], "col2_2", true, false, 0, 1, "col2_2", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ConflictSimpleComplexColumns()
{
DataSet ds = GetDataSet(_xml18, null);
Expand All @@ -377,7 +377,7 @@ public void ConflictSimpleComplexColumns()
DataSetAssertion.AssertForeignKeyConstraint("fkey", dr.ChildKeyConstraint, "table_col", AcceptRejectRule.None, Rule.Cascade, Rule.Cascade, new string[] { "table_Id" }, new string[] { "table_Id" });
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ConflictColumnTable()
{
DataSet ds = GetDataSet(_xml19, null);
Expand All @@ -398,7 +398,7 @@ public void ConflictColumnTable()
DataSetAssertion.AssertForeignKeyConstraint("fkey", dr.ChildKeyConstraint, "table_col", AcceptRejectRule.None, Rule.Cascade, Rule.Cascade, new string[] { "table_Id" }, new string[] { "table_Id" });
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ConflictColumnTableAttribute()
{
// Conflicts between a column and a table, additionally an attribute.
Expand All @@ -421,7 +421,7 @@ public void ConflictColumnTableAttribute()
DataSetAssertion.AssertForeignKeyConstraint("fkey", dr.ChildKeyConstraint, "table_col", AcceptRejectRule.None, Rule.Cascade, Rule.Cascade, new string[] { "table_Id" }, new string[] { "table_Id" });
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ConflictAttributeDataTable()
{
Assert.Throws<DataException>(() =>
Expand All @@ -433,7 +433,7 @@ public void ConflictAttributeDataTable()
});
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ConflictExistingPrimaryKey()
{
Assert.Throws<ConstraintException>(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private DataSet CreateTestSet()
return ds;
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void SingleElementTreatmentDifference()
{
// This is one of the most complicated case. When the content
Expand Down Expand Up @@ -149,7 +149,7 @@ public void SingleElementTreatmentDifference()
DataSetAssertion.AssertDataTable("complex", ds.Tables[0], "Root", 1, 0, 0, 0, 0, 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void SuspiciousDataSetElement()
{
string schema = @"<?xml version='1.0'?>
Expand All @@ -174,7 +174,7 @@ public void SuspiciousDataSetElement()
DataSetAssertion.AssertDataTable("table", ds.Tables[0], "elem", 2, 0, 0, 0, 0, 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void UnusedComplexTypesIgnored()
{
string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' id='hoge'>
Expand Down Expand Up @@ -213,7 +213,7 @@ public void SimpleTypeComponentsIgnored()
DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 0, 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void IsDataSetAndTypeIgnored()
{
string xsbase = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
Expand Down Expand Up @@ -243,7 +243,7 @@ public void IsDataSetAndTypeIgnored()
DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void NestedReferenceNotAllowed()
{
string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
Expand Down Expand Up @@ -272,7 +272,7 @@ public void NestedReferenceNotAllowed()
});
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void IsDataSetOnLocalElementIgnored()
{
string xsbase = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
Expand All @@ -294,7 +294,7 @@ public void IsDataSetOnLocalElementIgnored()
DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void LocaleOnRootWithoutIsDataSet()
{
using (new ThreadCultureChange("fi-FI"))
Expand Down Expand Up @@ -323,7 +323,7 @@ public void LocaleOnRootWithoutIsDataSet()
}


[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ElementHasIdentityConstraint()
{
string constraints = @"
Expand Down Expand Up @@ -381,7 +381,7 @@ public void ElementHasIdentityConstraint()
Assert.Equal(0, ds.Relations.Count);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void PrefixedTargetNS()
{
string xs = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata' xmlns:x='urn:foo' targetNamespace='urn:foo' elementFormDefault='qualified'>
Expand Down Expand Up @@ -477,7 +477,7 @@ private void ReadTest1Check(DataSet ds)
new string[] { "Column1_3" });
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
// 001-004
public void TestSampleFileNoTables()
{
Expand Down Expand Up @@ -510,7 +510,7 @@ public void TestSampleFileNoTables()
DataSetAssertion.AssertDataSet("004", ds, "NewDataSet", 0, 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void TestSampleFileSimpleTables()
{
var ds = new DataSet();
Expand Down Expand Up @@ -547,7 +547,7 @@ public void TestSampleFileSimpleTables()
DataSetAssertion.AssertDataColumn("att2", dt.Columns["att2"], "att2", true, false, 0, 1, "att2", MappingType.Attribute, typeof(int), 2, string.Empty, -1, string.Empty, /*1*/-1, string.Empty, false, false);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void TestSampleFileComplexTables()
{
// Nested simple type element
Expand Down Expand Up @@ -608,7 +608,7 @@ public void TestSampleFileComplexTables()
DataSetAssertion.AssertDataColumn("id", dt.Columns[1], "uno_Id", true, false, 0, 1, "uno_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void TestSampleFileComplexTables3()
{
var ds = new DataSet();
Expand Down Expand Up @@ -639,7 +639,7 @@ public void TestSampleFileComplexTables3()
DataSetAssertion.AssertDataColumn("simple", dt.Columns[1], "e_text", false, false, 0, 1, "e_text", MappingType.SimpleContent, typeof(decimal), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void TestSampleFileXPath()
{
var ds = new DataSet();
Expand Down Expand Up @@ -681,7 +681,7 @@ public void TestSampleFileXPath()
</xs:schema>"));
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void TestAnnotatedRelation1()
{
var ds = new DataSet();
Expand Down Expand Up @@ -732,7 +732,7 @@ public void TestAnnotatedRelation1()
DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "rel", false, new string[] { "pk" }, new string[] { "fk" }, false, false);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void TestAnnotatedRelation2()
{
var ds = new DataSet();
Expand Down Expand Up @@ -783,7 +783,7 @@ public void TestAnnotatedRelation2()
DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "rel", true, new string[] { "pk" }, new string[] { "fk" }, false, false);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void RepeatableSimpleElement()
{
var ds = new DataSet();
Expand Down Expand Up @@ -811,7 +811,7 @@ public void RepeatableSimpleElement()
DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "Foo_Bar", true, new string[] { "Foo_Id" }, new string[] { "Foo_Id" }, true, true);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void TestMoreThanOneRepeatableColumns()
{
var ds = new DataSet();
Expand Down Expand Up @@ -861,7 +861,7 @@ public void AutoIncrementStep()
Assert.True(ds.GetXmlSchema().IndexOf("AutoIncrementStep") > 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ReadConstraints()
{
var ds = new DataSet();
Expand Down Expand Up @@ -904,7 +904,7 @@ public void ReadConstraints()
Assert.Equal("fk1", ds.Tables[1].Constraints[0].ConstraintName);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ReadAnnotatedRelations_MultipleColumns()
{
var ds = new DataSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class DataSetReadXmlTest
</xs:schema>";
private const string schema2 = schema1 + xml8;

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ReadSimpleAuto()
{
DataSet ds;
Expand Down Expand Up @@ -285,7 +285,7 @@ public void ReadSimpleIgnoreSchema()
"NewDataSet", 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ReadSimpleInferSchema()
{
DataSet ds;
Expand Down Expand Up @@ -606,7 +606,7 @@ public void SequentialRead2()
DataSetAssertion.AssertDataTable("#3", ds.Tables[0], "root", 1, 2, 0, 0, 0, 0);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ReadComplexElementDocument()
{
var ds = new DataSet();
Expand Down Expand Up @@ -639,7 +639,7 @@ public void IgnoreSchemaShouldFillData()
Assert.Equal(0, dt.Rows.Count);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void NameConflictDSAndTable()
{
string xml = @"<PriceListDetails>
Expand All @@ -657,7 +657,7 @@ public void NameConflictDSAndTable()
Assert.NotNull(ds.Tables["PriceListDetails"]);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void ColumnOrder()
{
string xml = "<?xml version=\"1.0\" standalone=\"yes\"?>" +
Expand Down Expand Up @@ -690,7 +690,7 @@ public void ColumnOrder()
Assert.Equal(3, ds.Tables[0].Columns[3].Ordinal);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void XmlSpace()
{
string xml = "<?xml version=\"1.0\" standalone=\"yes\"?>" +
Expand Down
Loading