Skip to content

Commit 4f0a94a

Browse files
Fix up DefaultDocumentContextFactory test to use PathUtilities.CreateRootedPath()
1 parent eba5658 commit 4f0a94a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DefaultDocumentContextFactoryTest.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public DefaultDocumentContextFactoryTest(ITestOutputHelper testOutput)
3939
public void TryCreateAsync_CanNotResolveDocument_ReturnsNull()
4040
{
4141
// Arrange
42-
var uri = new Uri("C:/path/to/file.cshtml");
42+
var filePath = PathUtilities.CreateRootedPath("path", "to", "file.cshtml");
43+
var uri = new Uri(filePath);
4344
var factory = new DefaultDocumentContextFactory(_projectSnapshotManagerAccessor, new TestDocumentResolver(), _documentVersionCache, LoggerFactory);
4445

4546
// Act
@@ -53,7 +54,8 @@ public void TryCreateAsync_CanNotResolveDocument_ReturnsNull()
5354
public void TryCreateForOpenDocumentAsync_CanNotResolveDocument_ReturnsNull()
5455
{
5556
// Arrange
56-
var uri = new Uri("C:/path/to/file.cshtml");
57+
var filePath = PathUtilities.CreateRootedPath("path", "to", "file.cshtml");
58+
var uri = new Uri(filePath);
5759
var factory = new DefaultDocumentContextFactory(_projectSnapshotManagerAccessor, new TestDocumentResolver(), _documentVersionCache, LoggerFactory);
5860

5961
// Act
@@ -67,7 +69,8 @@ public void TryCreateForOpenDocumentAsync_CanNotResolveDocument_ReturnsNull()
6769
public void TryCreateForOpenDocumentAsync_CanNotResolveVersion_ReturnsNull()
6870
{
6971
// Arrange
70-
var uri = new Uri("C:/path/to/file.cshtml");
72+
var filePath = PathUtilities.CreateRootedPath("path", "to", "file.cshtml");
73+
var uri = new Uri(filePath);
7174
var documentSnapshot = TestDocumentSnapshot.Create(uri.GetAbsoluteOrUNCPath());
7275
var documentResolver = new TestDocumentResolver(documentSnapshot);
7376
var factory = new DefaultDocumentContextFactory(_projectSnapshotManagerAccessor, documentResolver, _documentVersionCache, LoggerFactory);
@@ -83,7 +86,8 @@ public void TryCreateForOpenDocumentAsync_CanNotResolveVersion_ReturnsNull()
8386
public void TryCreateAsync_ResolvesContent()
8487
{
8588
// Arrange
86-
var uri = new Uri("C:/path/to/file.cshtml");
89+
var filePath = PathUtilities.CreateRootedPath("path", "to", "file.cshtml");
90+
var uri = new Uri(filePath);
8791
var documentSnapshot = TestDocumentSnapshot.Create(uri.GetAbsoluteOrUNCPath());
8892
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(string.Empty, documentSnapshot.FilePath));
8993
documentSnapshot.With(codeDocument);
@@ -103,7 +107,8 @@ public void TryCreateAsync_ResolvesContent()
103107
public void TryCreateAsync_WithProjectContext_Resolves()
104108
{
105109
// Arrange
106-
var uri = new Uri("C:/path/to/file.cshtml");
110+
var filePath = PathUtilities.CreateRootedPath("path", "to", "file.cshtml");
111+
var uri = new Uri(filePath);
107112
var documentSnapshot = TestDocumentSnapshot.Create(uri.GetAbsoluteOrUNCPath());
108113
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(string.Empty, documentSnapshot.FilePath));
109114
documentSnapshot.With(codeDocument);
@@ -129,7 +134,8 @@ public void TryCreateAsync_WithProjectContext_Resolves()
129134
public void TryCreateAsync_WithProjectContext_DoesntUseSnapshotResolver()
130135
{
131136
// Arrange
132-
var uri = new Uri("C:/path/to/file.cshtml");
137+
var filePath = PathUtilities.CreateRootedPath("path", "to", "file.cshtml");
138+
var uri = new Uri(filePath);
133139
var documentSnapshot = TestDocumentSnapshot.Create(uri.GetAbsoluteOrUNCPath());
134140
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(string.Empty, documentSnapshot.FilePath));
135141
documentSnapshot.With(codeDocument);
@@ -156,7 +162,8 @@ public void TryCreateAsync_WithProjectContext_DoesntUseSnapshotResolver()
156162
public async Task TryCreateForOpenDocumentAsync_ResolvesContent()
157163
{
158164
// Arrange
159-
var uri = new Uri("C:/path/to/file.cshtml");
165+
var filePath = PathUtilities.CreateRootedPath("path", "to", "file.cshtml");
166+
var uri = new Uri(filePath);
160167
var documentSnapshot = TestDocumentSnapshot.Create(uri.GetAbsoluteOrUNCPath());
161168
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create(string.Empty, documentSnapshot.FilePath));
162169
documentSnapshot.With(codeDocument);

0 commit comments

Comments
 (0)