Skip to content

Commit

Permalink
Fix test runtime errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkoshevoi committed Sep 11, 2019
1 parent 8a8f1e9 commit 8c43b7e
Showing 1 changed file with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeQuality.Analyzers.QualityGuidelines;
using Test.Utilities;
using Xunit;
Expand All @@ -20,16 +19,6 @@ protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
return new AssigningSymbolAndItsMemberInSameStatement();
}

private DiagnosticResult GetCSharpResultAt(int line, int column, string symbolName)
{
return GetCSharpResultAt(line, column, AssigningSymbolAndItsMemberInSameStatement.Rule, symbolName);
}

private DiagnosticResult GetBasicResultAt(int line, int column, string symbolName)
{
return GetBasicResultAt(line, column, AssigningSymbolAndItsMemberInSameStatement.Rule, symbolName);
}

[Fact]
public void CSharpReassignLocalVariableAndReferToItsField()
{
Expand All @@ -43,12 +32,12 @@ public class Test
{
public void Method()
{
C a, b;
C a = new C(), b = new C();
a.Field = a = b;
}
}
",
GetCSharpResultAt(12, 9, "a", "Field"));
GetCSharpResultAt(12, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "a", "Field"));
}

[Fact]
Expand All @@ -64,12 +53,12 @@ public class Test
{
public void Method()
{
C a, b, c;
C a = new C(), b = new C(), c;
a.Property = c = a = b;
}
}
",
GetCSharpResultAt(12, 9, "a", "Property"));
GetCSharpResultAt(12, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "a", "Property"));
}

[Fact]
Expand All @@ -85,12 +74,12 @@ public class Test
{
public void Method()
{
C a, b;
C a = new C(), b = new C();
a.Property.Property = a.Property = b;
}
}
",
GetCSharpResultAt(12, 9, "a.Property", "Property"));
GetCSharpResultAt(12, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "a.Property", "Property"));
}

[Fact]
Expand All @@ -106,13 +95,13 @@ public class Test
{
public void Method()
{
C a, b;
C a = new C(), b = new C();
a.Property.Property = a.Property = a = b;
}
}
",
GetCSharpResultAt(12, 9, "a.Property", "Property"),
GetCSharpResultAt(12, 31, "a", "Property"));
GetCSharpResultAt(12, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "a.Property", "Property"),
GetCSharpResultAt(12, 31, AssigningSymbolAndItsMemberInSameStatement.Rule, "a", "Property"));
}

[Fact]
Expand All @@ -134,7 +123,7 @@ public void Method()
}
}
",
GetCSharpResultAt(13, 9, "x", "Field"));
GetCSharpResultAt(13, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "x", "Field"));
}

[Fact]
Expand All @@ -156,7 +145,7 @@ public void Method()
}
}
",
GetCSharpResultAt(13, 9, "x.Property", "Property"));
GetCSharpResultAt(13, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "x.Property", "Property"));
}

[Fact]
Expand All @@ -178,8 +167,8 @@ public void Method()
}
}
",
GetCSharpResultAt(13, 9, "x.Property", "Property"),
GetCSharpResultAt(13, 31, "x", "Property"));
GetCSharpResultAt(13, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "x.Property", "Property"),
GetCSharpResultAt(13, 31, AssigningSymbolAndItsMemberInSameStatement.Rule, "x", "Property"));
}


Expand All @@ -203,8 +192,8 @@ public void Method()
}
}
",
GetCSharpResultAt(14, 9, "x.Property", "Property"),
GetCSharpResultAt(14, 31, "x", "Property"));
GetCSharpResultAt(14, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "x.Property", "Property"),
GetCSharpResultAt(14, 31, AssigningSymbolAndItsMemberInSameStatement.Rule, "x", "Property"));
}

[Fact]
Expand All @@ -220,7 +209,7 @@ public class Test
{
public void Method()
{
C a, b;
C a = new C(), b;
a.Property = b = a;
}
}
Expand All @@ -240,7 +229,7 @@ public class Test
{
public void Method()
{
C a, b, c;
C a = new C(), b = new C(), c;
b.Property.Property = a.Property = b;
}
}
Expand All @@ -260,7 +249,7 @@ public class Test
{
public void Method()
{
C a, b, c;
C a = new C(), b = new C(), c = new C();
b.Property.Property = a.Property = c;
}
}
Expand All @@ -280,12 +269,12 @@ public class Test
{
public void Method(C b)
{
C a;
C a = new C();
b.Property = b = a;
}
}
",
GetCSharpResultAt(12, 9, "b", "Property"));
GetCSharpResultAt(12, 9, AssigningSymbolAndItsMemberInSameStatement.Rule, "b", "Property"));
}

[Fact]
Expand All @@ -305,7 +294,7 @@ public void Method()
a.Field = a = b;
}
}
");
", TestValidationMode.AllowCompileErrors);
}

[Fact]
Expand All @@ -325,7 +314,7 @@ public void Method()
a.Property = c = a = b;
}
}
");
", TestValidationMode.AllowCompileErrors);
}
}
}

0 comments on commit 8c43b7e

Please sign in to comment.