Skip to content

Commit

Permalink
Remove TestDocumentMappingService (#10976)
Browse files Browse the repository at this point in the history
This was only used for a single test and the implementation is trivial
to mock. I noticed this when I saw that `TestDocumentMappingService`
still "implemented" `GetLanguageKind`, which no longer exists on
`IDocumentMappingService`.
  • Loading branch information
DustinCampbell authored Oct 8, 2024
2 parents f02835b + 2082848 commit 46dbd5d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public DelegatedCompletionListProvider(
IClientConnection clientConnection,
CompletionListCache completionListCache)
{
_responseRewriters = responseRewriters.OrderBy(rewriter => rewriter.Order).ToImmutableArray();
_responseRewriters = responseRewriters.OrderByAsArray(static x => x.Order);
_documentMappingService = documentMappingService;
_clientConnection = clientConnection;
_completionListCache = completionListCache;
Expand All @@ -57,7 +57,9 @@ public DelegatedCompletionListProvider(
Guid correlationId,
CancellationToken cancellationToken)
{
var positionInfo = await _documentMappingService.GetPositionInfoAsync(documentContext, absoluteIndex, cancellationToken).ConfigureAwait(false);
var positionInfo = await _documentMappingService
.GetPositionInfoAsync(documentContext, absoluteIndex, cancellationToken)
.ConfigureAwait(false);

if (positionInfo.LanguageKind == RazorLanguageKind.Razor)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Moq;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -284,15 +287,16 @@ public async Task ShouldIncludeSnippets(string input, bool shouldIncludeSnippets
var codeDocument = CreateCodeDocument(code);
var documentContext = TestDocumentContext.From("C:/path/to/file.cshtml", codeDocument, hostDocumentVersion: 1337);

var documentMappingService = new TestDocumentMappingService()
{
LanguageKind = RazorLanguageKind.Html,
GeneratedPosition = new LinePosition(0, cursorPosition)
};
var generatedPosition = new LinePosition(0, cursorPosition);

var documentMappingServiceMock = new StrictMock<IDocumentMappingService>();
documentMappingServiceMock
.Setup(x => x.TryMapToGeneratedDocumentPosition(It.IsAny<IRazorGeneratedDocument>(), It.IsAny<int>(), out generatedPosition, out It.Ref<int>.IsAny))
.Returns(true);

var completionProvider = new DelegatedCompletionListProvider(
Array.Empty<DelegatedCompletionResponseRewriter>(),
documentMappingService,
responseRewriters: [],
documentMappingServiceMock.Object,
clientConnection,
new CompletionListCache());

Expand Down

This file was deleted.

0 comments on commit 46dbd5d

Please sign in to comment.