Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Add some regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ericstj committed Aug 3, 2018
1 parent e72bb35 commit 045b5f9
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/Microsoft.DotNet.CodeFormatting.Tests/Rules/CombinationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,69 @@ public void RequiredRuntimeAttribute()
ToggleRule(UsingLocationRule.Name, enabled: true);
Verify(source, expected);
}

[Fact]
public void Issue268()
{
var text = @"
using System.Collections.Generic;
internal class C
{
private void M<TValue>()
{
Dictionary<string, Stack<TValue>> dict = new Dictionary<string, Stack<TValue>>();
dict.TryGetValue(""key"", out Stack<TValue> stack);
}
}";

Verify(text, expected:text);
}

[Fact]
public void Issue272()
{
var text = @"
using System.Collections.Generic;
internal class C
{
private object myVariable;
private void M()
{
Dictionary<string, object> dict = new Dictionary<string, object>()
{
{ ""key"", new object() }
};
dict.TryGetValue(""key"", out object myVariable);
this.myVariable = myVariable;
}
}";
var expected = @"
using System.Collections.Generic;
internal class C
{
private object _myVariable;
private void M()
{
Dictionary<string, object> dict = new Dictionary<string, object>()
{
{ ""key"", new object() }
};
dict.TryGetValue(""key"", out object myVariable);
_myVariable = myVariable;
}
}";

Verify(text, expected);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,58 @@ int M(C p)

Verify(text, expected);
}

[Fact]
public void Issue258()
{
var text = @"
class C
{
private (string name, string value) myTuple;
}
";
var expected = @"
class C
{
private (string name, string value) _myTuple;
}
";

Verify(text, expected, runFormatter: false);
}

[Fact]
public void Issue241()
{
var text = @"
class C
{
private bool streamObjects;
/// <summary>
/// A collection in which objects that are written using the WriteError
/// method are accumulated if <see cref=""streamObjects"" /> is false.
/// </summary>
private List<string> errors;
}
";
var expected = @"
class C
{
private bool _streamObjects;
/// <summary>
/// A collection in which objects that are written using the WriteError
/// method are accumulated if <see cref=""_streamObjects"" /> is false.
/// </summary>
private List<string> _errors;
}
";

Verify(text, expected, runFormatter: false);
}
}

public sealed class VisualBasicFields : PrivateFieldNamingRuleTests
Expand Down

0 comments on commit 045b5f9

Please sign in to comment.