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

Tests fixes #228

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void ValidWhenIsEqualToConstraintUsed()
var actual = ""abc"";
Assert.That(actual, Is.EqualTo(""bcd""));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -201,7 +201,7 @@ public void ValidWhenIsNotEqualToConstraintUsed()
var actual = ""abc"";
Assert.That(actual, Is.Not.EqualTo(""bcd""));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -211,7 +211,7 @@ public void ValidOtherMethodUsed()
var actual = ""abc"";
Assert.That(actual.Contains(""bc""));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void NoDiagnosticWhenListOtherMethodsUsed()
Assert.That(new List<int> { 1, 2, 3 }.Remove(1));",
additionalUsings: "using System.Collections.Generic;");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -89,7 +89,7 @@ public void NoDiagnosticWhenOtherTypesUsed()
var testCode = TestUtility.WrapInTestMethod(@"
Assert.That(""1, 2, 3"".Contains(""1""));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ public void AnalyzeStringBooleanMethod_AssertThat_IsFalse(string method, string
[Test]
public void ValidForUnsupportedStringMethods()
{
var testCode = TestUtility.WrapInTestMethod(@"Assert.That(""abc"".IsNormalized());");
var testCode = TestUtility.WrapInTestMethod(@"Assert.That(""abc"".IsNormalized());");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
public void ValidForNonStringMethods()
{
var testCode = TestUtility.WrapInTestMethod(
@"Assert.That(new List<string> { ""a"",""ab""}.Contains(""ab""));");
@"Assert.That(new System.Collections.Generic.List<string> { ""a"",""ab""}.Contains(""ab""));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class EqualToIncompatibleTypesAnalyzerTests
ExpectedDiagnostic.Create(AnalyzerIdentifiers.EqualToIncompatibleTypes);

private static readonly string[] NumericTypes = new[] {
"decimal", "double", "float", "int", "unit", "long", "ulong", "short", "ushort"
"decimal", "double", "float", "int", "uint", "long", "ulong", "short", "ushort"
};

[Test]
Expand Down Expand Up @@ -323,7 +323,7 @@ public void NoDiagnosticWhenActualAndExpectedTypesAreSame()
var expected = """";
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -334,7 +334,7 @@ public void NoDiagnosticWhenActualAndExpectedTypesAreSame_WithNegatedAssert()
var expected = """";
Assert.That(actual, Is.Not.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -344,7 +344,7 @@ public void NoDiagnosticWhenActualAndExpectedTypesAreSame_WithLambdaActualValue(
var expected = """";
Assert.That(() => """", Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -355,7 +355,7 @@ public void NoDiagnosticWhenActualAndExpectedTypesAreSame_WithFuncActualValue()
var expected = """";
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -366,7 +366,7 @@ public void NoDiagnosticWhenActualAndExpectedTypesAreSame_WithLocalFunctionActua
var expected = """";
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -377,7 +377,7 @@ public void NoDiagnosticWhenActualAndExpectedTypesAreSame_WithTaskActualValue()
var expected = """";
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -398,7 +398,7 @@ public void TestMethod()
}
}");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -419,7 +419,7 @@ public void NoDiagnosticWhenActualTypeInheritsExpected()
}
}");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -432,7 +432,7 @@ public void NoDiagnosticForNumericTypes(
{expectedType} expected = 1;
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -443,7 +443,7 @@ public void NoDiagnosticForCharAndInt()
var expected = (int)actual;
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -463,7 +463,7 @@ public void EnumTest()
}
}");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -483,7 +483,7 @@ public void EnumTest()
}
}");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}


Expand All @@ -495,7 +495,7 @@ public void NoDiagnosticForStreams()
var expected = new System.IO.MemoryStream();
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -507,7 +507,7 @@ public void NoDiagnosticForDifferentCollectionsWithSameType()
Assert.That(actual, Is.EqualTo(expected));",
additionalUsings: "using System.Collections.Generic;");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -519,7 +519,7 @@ public void NoDiagnosticForDifferentCollectionsWithNumerics()
Assert.That(actual, Is.EqualTo(expected));",
additionalUsings: "using System.Collections.Generic;");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -531,7 +531,7 @@ public void NoDiagnosticForDictionariesOfNumerics()
Assert.That(actual, Is.EqualTo(expected));",
additionalUsings: "using System.Collections.Generic;");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -540,9 +540,10 @@ public void NoDiagnosticForKeyValuePairsOfNumerics()
var testCode = TestUtility.WrapInTestMethod(@"
var actual = new KeyValuePair<string, int>(""a"", 1);
var expected = new KeyValuePair<string, double>(""a"", 1.0);
Assert.That(actual, Is.EqualTo(expected));");
Assert.That(actual, Is.EqualTo(expected));",
additionalUsings: "using System.Collections.Generic;");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -553,7 +554,7 @@ public void NoDiagnosticForTuplesWithCompatibleElementTypes()
var expected = Tuple.Create(""1"", 2);
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -564,7 +565,7 @@ public void NoDiagnosticForValueTuplesWithCompatibleElementTypes()
var expected = (""1"", 2);
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -589,7 +590,7 @@ public void TestMethod()
}
}");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -614,7 +615,7 @@ public void TestMethod()
}
}");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -625,7 +626,7 @@ public void NoDiagnosticWhenActualIsDynamic()
var expected = """";
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -636,7 +637,7 @@ public void NoDiagnosticWhenExpectedIsDynamic()
dynamic expected = 2;
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -657,7 +658,7 @@ public void TestMethod()
}
}");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -678,7 +679,7 @@ public void NoDiagnosticForOtherConstraints()
}
}");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -688,7 +689,7 @@ public void NoDiagnosticWhenUsedWithPropertyConstraint()
var actual = ""abc"";
Assert.That(actual, Has.Property(""Length"").EqualTo(3));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -699,7 +700,7 @@ public void NoDiagnosticWhenActualIsMatchingNullableType()
int expected = 5;
Assert.That(actual, Is.EqualTo(5));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -710,7 +711,7 @@ public void NoDiagnosticWhenExpectedIsMatchingNullableType()
int? expected = 5;
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -721,7 +722,7 @@ public void NoDiagnosticWhenActualIsNumericNullableType()
double expected = 5.0;
Assert.That(actual, Is.EqualTo(expected));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -731,7 +732,7 @@ public void NoDiagnosticWhenConditionalPrefixPresent()
bool shouldBePresent = true;
Assert.That(new[] { 1, 2, 3 }, (shouldBePresent ? Has.Some : Has.None).EqualTo(2));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -742,7 +743,7 @@ public void NoDiagnosticWhenVariableIsPartOfConstraint()
var constraintModifier = (shouldBePresent ? Has.Some : Has.None);
Assert.That(new[] { 1, 2, 3 }, constraintModifier.EqualTo(2));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand All @@ -752,7 +753,7 @@ public void NoDiagnosticWhenObjectComparedToInt()
object actual = 3;
Assert.That(actual, Is.EqualTo(3));");

AnalyzerAssert.NoAnalyzerDiagnostics(analyzer, testCode);
AnalyzerAssert.Valid(analyzer, testCode);
}

[Test]
Expand Down
Loading