diff --git a/YarnSpinner.LanguageServer.Tests/CommandTests.cs b/YarnSpinner.LanguageServer.Tests/CommandTests.cs index c07bccb78..f07391ede 100644 --- a/YarnSpinner.LanguageServer.Tests/CommandTests.cs +++ b/YarnSpinner.LanguageServer.Tests/CommandTests.cs @@ -77,7 +77,8 @@ public async Task Server_OnAddNodeCommand_ReturnsTextEdit() nodeInfo = await GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(filePath)); - nodeInfo.Nodes.Should().HaveCount(4, "because the file has four nodes"); + // Remember how many nodes we had before making the change + var count = nodeInfo.Nodes.Count; var result = await client.ExecuteCommand(new ExecuteCommandParams { @@ -100,7 +101,7 @@ public async Task Server_OnAddNodeCommand_ReturnsTextEdit() nodeInfo = await nodesChangedAfterChangingText; - nodeInfo.Nodes.Should().HaveCount(5, "because we added a node"); + nodeInfo.Nodes.Should().HaveCount(count + 1, "because we added a node"); nodeInfo.Nodes.Should() .Contain(n => n.Title == "Node", "because the new node should be called Title") @@ -121,7 +122,8 @@ public async Task Server_OnRemoveNodeCommand_ReturnsTextEdit() NodesChangedParams? nodeInfo = await getInitialNodesChanged; - nodeInfo.Nodes.Should().HaveCount(4, "because the file has four nodes"); + // Remember how many nodes we had before making the change + var count = nodeInfo.Nodes.Count; // Expect to receive a 'nodes changed' notification Task nodesChangedAfterRemovingNode = GetNodesChangedNotificationAsync(n => n.Uri.ToString().Contains(filePath)); @@ -143,7 +145,7 @@ public async Task Server_OnRemoveNodeCommand_ReturnsTextEdit() nodeInfo = await nodesChangedAfterRemovingNode; - nodeInfo.Nodes.Should().HaveCount(3, "because we removed a node"); + nodeInfo.Nodes.Should().HaveCount(count - 1, "because we removed a node"); } [Fact] @@ -330,8 +332,6 @@ public async Task Server_OnGetDebugInfo_ReturnsDebugInfo() }); // Then - result.Should().HaveCount(3, "there are three projects in the workspace"); - var firstProject = result.Should().Contain(info => DocumentUri.GetFileSystemPath(info.SourceProjectUri!) == project1Path).Subject; firstProject.Variables.Should().NotBeEmpty(); diff --git a/YarnSpinner.LanguageServer.Tests/CompletionTests.cs b/YarnSpinner.LanguageServer.Tests/CompletionTests.cs index 969b7e0e7..c9fcc0bdf 100644 --- a/YarnSpinner.LanguageServer.Tests/CompletionTests.cs +++ b/YarnSpinner.LanguageServer.Tests/CompletionTests.cs @@ -45,6 +45,7 @@ public async Task Server_OnCompletingStartOfCommand_ReturnsValidCompletions() completionResults.Should().NotContain(i => i.Kind == CompletionItemKind.Snippet, "we are in the middle of a command and inserting a snippet is not appropriate"); + completionResults.Should().NotBeEmpty(); completionResults.Should().AllSatisfy(item => { item.TextEdit!.TextEdit!.Range.Start.Should().BeEquivalentTo(startOfCommand, "the completion item's range should be the end of the << character"); @@ -82,6 +83,7 @@ public async Task Server_OnCompletingPartialCommand_ReturnsValidCompletionRange( // Then completionResults.Should().Contain(item => item.Kind == CompletionItemKind.Function, "the completion list should contain functions"); + completionResults.Should().NotBeEmpty(); completionResults.Should().AllSatisfy(result => { result.TextEdit!.TextEdit!.Range.Start.Should().BeEquivalentTo(startOfCommand, "the completion item's edit should start at the end of the << token"); @@ -113,6 +115,7 @@ public async Task Server_OnCompletingJumpCommand_ReturnsNodeNames() }); // Then + completionResults.Should().NotBeEmpty(); completionResults.Should().AllSatisfy(item => { item.Kind.Should().Be(CompletionItemKind.Method, "node names are expected when completing a jump command"); @@ -149,6 +152,7 @@ public async Task Server_OnCompletingPartialJumpCommand_ReturnsNodeNames() }); // Then + completionResults.Should().NotBeEmpty(); completionResults.Should().AllSatisfy(item => { item.Kind.Should().Be(CompletionItemKind.Method, "node names are expected when completing a jump command"); diff --git a/YarnSpinner.LanguageServer.Tests/WorkspaceTests.cs b/YarnSpinner.LanguageServer.Tests/WorkspaceTests.cs index 92262a2e3..caeeebeba 100644 --- a/YarnSpinner.LanguageServer.Tests/WorkspaceTests.cs +++ b/YarnSpinner.LanguageServer.Tests/WorkspaceTests.cs @@ -23,8 +23,8 @@ public void Projects_CanOpen() project.ReloadProjectFromDisk(false); // Then - project.Files.Should().HaveCount(2); - project.Nodes.Should().HaveCount(5); + project.Files.Should().NotBeEmpty(); + project.Nodes.Should().NotBeEmpty(); project.Files.Should().AllSatisfy(file => file.Project.Should().Be(project)); var testFilePath = DocumentUri.FromFileSystemPath(Path.Combine(TestUtility.PathToTestWorkspace, "Project1", "Test.yarn")); @@ -43,7 +43,7 @@ public void Workspaces_CanOpen() { workspace.Projects.SelectMany(p => p.Nodes).Should().NotBeEmpty(); - workspace.Projects.Should().HaveCount(3); + workspace.Projects.Should().NotBeEmpty(); // The node NotIncludedInProject is inside a file that is not // included in a .yarnproject; because we have opened a workspace