Skip to content

Commit a383201

Browse files
committed
Adjust tests.
1 parent eef7c86 commit a383201

File tree

2 files changed

+66
-62
lines changed

2 files changed

+66
-62
lines changed

src/PortToTripleSlash/tests/PortToTripleSlash/PortToTripleSlash.FileSystem.Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.IO;

src/PortToTripleSlash/tests/PortToTripleSlash/PortToTripleSlash.Strings.Tests.cs

Lines changed: 65 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,24 +1306,28 @@ public Task Preserve_DoubleSlash_Comments(bool skipRemarks)
13061306
</Members>
13071307
</Type>";
13081308

1309-
string originalCode = @"namespace MyNamespace;
1310-
// Comment on top of type
1311-
public class MyClass
1309+
string originalCode = @"namespace MyNamespace
13121310
{
1313-
// Comment on top of constructor
1314-
public MyClass() { }
1311+
// Comment on top of type
1312+
public class MyClass
1313+
{
1314+
// Comment on top of constructor
1315+
public MyClass() { }
1316+
}
13151317
}";
13161318

1317-
string expectedCode = @"namespace MyNamespace;
1318-
/// <summary>This is the MyClass type summary.</summary>" +
1319-
GetRemarks(skipRemarks, "MyClass type") +
1320-
@"// Comment on top of type
1321-
public class MyClass
1319+
string expectedCode = @"namespace MyNamespace
13221320
{
1323-
/// <summary>This is the MyClass constructor summary.</summary>" +
1324-
GetRemarks(skipRemarks, "MyClass constructor", " ") +
1325-
@" // Comment on top of constructor
1326-
public MyClass() { }
1321+
// Comment on top of type
1322+
/// <summary>This is the MyClass type summary.</summary>" +
1323+
GetRemarks(skipRemarks, "MyClass type", " ") +
1324+
@" public class MyClass
1325+
{
1326+
// Comment on top of constructor
1327+
/// <summary>This is the MyClass constructor summary.</summary>" +
1328+
GetRemarks(skipRemarks, "MyClass constructor", " ") +
1329+
@" public MyClass() { }
1330+
}
13271331
}";
13281332

13291333
List<string> docFiles = new() { docFile };
@@ -1363,25 +1367,26 @@ public Task Override_Existing_TripleSlash_Comments(bool skipRemarks)
13631367
</Type>";
13641368

13651369
string originalCode = @"namespace MyNamespace {
1366-
/// <summary>Old MyClass type summary.</summary>
1367-
/// <remarks>Old MyClass type remarks.</remarks>
1368-
public class MyClass
1369-
{
1370-
/// <summary>Old MyClass constructor summary.</summary>
1371-
/// <remarks>Old MyClass constructor remarks.</remarks>
1372-
public MyClass() { }
1373-
}
1370+
/// <summary>Replaceable MyClass type summary.</summary>
1371+
/// <remarks>Unreplaceable MyClass type remarks.</remarks>
1372+
public class MyClass
1373+
{
1374+
/// <summary>Unreplaceable MyClass constructor summary.</summary>
1375+
/// <remarks>Replaceable MyClass constructor remarks.</remarks>
1376+
public MyClass() { }
1377+
}
13741378
}";
13751379

1380+
string ctorRemarks = skipRemarks ? "\n" : "\n /// <remarks>New MyClass constructor remarks.</remarks>\n";
13761381
string expectedCode = @"namespace MyNamespace {
1377-
/// <summary>New MyClass type summary.</summary>
1378-
/// <remarks>Old MyClass type remarks.</remarks>
1379-
public class MyClass
1380-
{
1381-
/// <summary>Old MyClass constructor summary.</summary>
1382-
/// <remarks>New MyClass constructor remarks.</remarks>
1383-
public MyClass() { }
1384-
}
1382+
/// <summary>New MyClass type summary.</summary>
1383+
/// <remarks>Unreplaceable MyClass type remarks.</remarks>
1384+
public class MyClass
1385+
{
1386+
/// <summary>Unreplaceable MyClass constructor summary.</summary>" +
1387+
ctorRemarks +
1388+
@" public MyClass() { }
1389+
}
13851390
}";
13861391

13871392
List<string> docFiles = new() { docFile };
@@ -1433,7 +1438,7 @@ public enum MyEnum
14331438

14341439
string expectedCode = @"namespace MyNamespace;
14351440
/// <summary>This is the MyEnum summary.</summary>" +
1436-
GetRemarks(skipRemarks, "MyEnum", " ") +
1441+
GetRemarks(skipRemarks, "MyEnum") +
14371442
@"public enum MyEnum
14381443
{
14391444
/// <summary>This is the MyEnum.Value1 summary.</summary>
@@ -1752,7 +1757,7 @@ public void MyVoidMethod() { }
17521757

17531758
string expectedCode = @"namespace MyNamespace;
17541759
/// <summary>This is the MyStruct summary.</summary>" +
1755-
GetRemarks(skipRemarks, "MyStruct", " ") +
1760+
GetRemarks(skipRemarks, "MyStruct") +
17561761
@"public struct MyStruct
17571762
{
17581763
/// <summary>This is the MyStruct constructor summary.</summary>" +
@@ -1775,8 +1780,7 @@ public void MyVoidMethod() { }
17751780
/// <param name=""withGenericArgument"">This is the MyGenericMethod withGenericArgument description.</param>
17761781
/// <returns>This is the MyGenericMethod returns description.</returns>" +
17771782
GetRemarks(skipRemarks, "MyGenericMethod", " ") +
1778-
@"
1779-
public T MyGenericMethod<T>(T withGenericArgument) => withGenericArgument;
1783+
@" public T MyGenericMethod<T>(T withGenericArgument) => withGenericArgument;
17801784
/// <summary>This is the MyField summary.</summary>" +
17811785
GetRemarks(skipRemarks, "MyField", " ") +
17821786
@" public double MyField;
@@ -1893,36 +1897,36 @@ public interface MyInterface
18931897
}";
18941898

18951899
string expectedCode = @"namespace MyNamespace;
1896-
/// <summary>This is the MyInterface summary.</summary>
1897-
/// <remarks>These are the MyInterface remarks.</remarks>
1898-
public interface MyInterface
1900+
/// <summary>This is the MyInterface summary.</summary>" +
1901+
GetRemarks(skipRemarks, "MyInterface") +
1902+
@"public interface MyInterface
18991903
{
1900-
/// <summary>This is the MyVoidMethod summary.</summary>
1901-
/// <remarks>These are the MyVoidMethod remarks.</remarks>
1902-
public void MyVoidMethod();
1904+
/// <summary>This is the MyVoidMethod summary.</summary>" +
1905+
GetRemarks(skipRemarks, "MyVoidMethod", " ") +
1906+
@" public void MyVoidMethod();
19031907
/// <summary>This is the MyIntMethod summary.</summary>
19041908
/// <param name=""withArgument"">This is the MyIntMethod withArgument description.</param>
1905-
/// <returns>This is the MyIntMethod returns description.</returns>
1906-
/// <remarks>These are the MyIntMethod remarks.</remarks>
1907-
public int MyIntMethod(int withArgument);
1909+
/// <returns>This is the MyIntMethod returns description.</returns>" +
1910+
GetRemarks(skipRemarks, "MyIntMethod", " ") +
1911+
@" public int MyIntMethod(int withArgument);
19081912
/// <summary>This is the MyGenericMethod summary.</summary>
19091913
/// <typeparam name=""T"">This is the MyGenericMethod type parameter description.</typeparam>
19101914
/// <param name=""withGenericArgument"">This is the MyGenericMethod withGenericArgument description.</param>
1911-
/// <returns>This is the MyGenericMethod returns description.</returns>
1912-
/// <remarks>These are the MyGenericMethod remarks.</remarks>
1913-
public T MyGenericMethod<T>(T withGenericArgument);
1915+
/// <returns>This is the MyGenericMethod returns description.</returns>" +
1916+
GetRemarks(skipRemarks, "MyGenericMethod", " ") +
1917+
@" public T MyGenericMethod<T>(T withGenericArgument);
19141918
/// <summary>This is the MySetProperty summary.</summary>
1915-
/// <value>This is the MySetProperty value.</value>
1916-
/// <remarks>These are the MySetProperty remarks.</remarks>
1917-
public double MySetProperty { set; }
1919+
/// <value>This is the MySetProperty value.</value>" +
1920+
GetRemarks(skipRemarks, "MySetProperty", " ") +
1921+
@" public double MySetProperty { set; }
19181922
/// <summary>This is the MyGetProperty summary.</summary>
1919-
/// <value>This is the MyGetProperty value.</value>
1920-
/// <remarks>These are the MyGetProperty remarks.</remarks>
1921-
public double MyGetProperty { get; }
1923+
/// <value>This is the MyGetProperty value.</value>" +
1924+
GetRemarks(skipRemarks, "MyGetProperty", " ") +
1925+
@" public double MyGetProperty { get; }
19221926
/// <summary>This is the MyGetSetProperty summary.</summary>
1923-
/// <value>This is the MyGetSetProperty value.</value>
1924-
/// <remarks>These are the MyGetSetProperty remarks.</remarks>
1925-
public double MyGetSetProperty { get; set; }
1927+
/// <value>This is the MyGetSetProperty value.</value>" +
1928+
GetRemarks(skipRemarks, "MyGetSetProperty", " ") +
1929+
@" public double MyGetSetProperty { get; set; }
19261930
}";
19271931

19281932
List<string> docFiles = new() { docFile };
@@ -1933,7 +1937,7 @@ public interface MyInterface
19331937
return TestWithStringsAsync(data, skipRemarks);
19341938
}
19351939

1936-
private string GetRemarks(bool skipRemarks, string apiName, string? spacing = "")
1940+
private static string GetRemarks(bool skipRemarks, string apiName, string spacing = "")
19371941
{
19381942
return skipRemarks ? @"
19391943
" : $@"
@@ -1946,9 +1950,9 @@ private static Task TestWithStringsAsync(StringTestData data, bool skipRemarks)
19461950

19471951
private static async Task TestWithStringsAsync(Configuration c, string assembly, StringTestData data)
19481952
{
1949-
Assert.True(data.XDocs.Any(), "No XDoc elements passed.");
1950-
Assert.True(data.OriginalCodeFiles.Any(), "No original code files passed.");
1951-
Assert.True(data.ExpectedCodeFiles.Any(), "No expected code files passed.");
1953+
Assert.NotEmpty(data.XDocs);
1954+
Assert.NotEmpty(data.OriginalCodeFiles);
1955+
Assert.NotEmpty(data.ExpectedCodeFiles);
19521956

19531957
c.IncludedAssemblies.Add(assembly);
19541958

@@ -1999,8 +2003,8 @@ private static async Task TestWithStringsAsync(Configuration c, string assembly,
19992003
Assert.True(symbolLocations.Any(), $"No symbol locations found for {resultDocId}.");
20002004
foreach (ResolvedLocation location in symbolLocations)
20012005
{
2002-
string newNode = location.NewNode.ToFullString();
2003-
Assert.Equal(expectedCode, newNode);
2006+
string actualCode = location.NewNode.ToFullString();
2007+
Assert.Equal(expectedCode, actualCode);
20042008
}
20052009
}
20062010
}

0 commit comments

Comments
 (0)