public void TestRegular() { ISymbolTableManager manager = new FakeSymbolManager(false, false); var provider = new HoverProvider(manager); //note: params do not matter. the fake returns a fixed symbol and does not respect the position. those methods are tested within the symbol table tests. var result = provider.GetHoverInformation(new Uri("file:///N:/u/l.l"), 0, 10); Assert.AreEqual(1, result.Range.Start.Line, "Start Line is not matching"); Assert.AreEqual(21, result.Range.Start.Character, "Start Char is not matching"); Assert.AreEqual(1, result.Range.End.Line, "End Line is not matching"); Assert.AreEqual(29, result.Range.End.Character, "End Char is not matching"); Console.WriteLine(result.Contents.MarkupContent.Value); string textExpectation = " **`barapapa`** *(line 2, l.l)*\n" + "* **Type:** N/A\n" + "* **Kind:** RootNode\n" + "* **Scope:** `_programRootNode`\n" + "* **Declaration:** line 1, l.l"; string actual = result.Contents.MarkupContent.Value.Replace("N:\\u\\l.l", "l.l"); Assert.AreEqual(textExpectation, actual, "Markup Content does not match"); }
public void TestAssembling() { ISymbolTableManager manager = new FakeSymbolManager(false, false); var provider = new RenameProvider(manager); //note: params do not matter. the fake returns a fixed symbol and does not respect the position. those methods are tested within the symbol table tests. var result = provider.GetRenameChanges("oink", new Uri("file:///N:/u/l.l"), 2, 22); Assert.AreEqual("file:///N:/u/l.l", result.Changes.Keys.First().ToString(), "The fake instance is not assigning URIs. It should be the default-null uri."); var changes = result.Changes.Values.First(); var aslist = changes.ToList(); aslist.Sort( (te1, te2) => (int)te1.Range.Start.Line - (int)te2.Range.Start.Line ); foreach (var c in aslist) { Assert.AreEqual("oink", c.NewText, "New Text was not as expected"); Assert.AreEqual(8, c.Range.End.Character - c.Range.Start.Character, "The Range was not as expected"); Assert.AreEqual(0, c.Range.End.Line - c.Range.Start.Line, "Edit is not on the same line"); } Assert.AreEqual(0, aslist[0].Range.Start.Line, "Edit 0 starts at wrong line"); Assert.AreEqual(10, aslist[0].Range.Start.Character, "Edit 0 starts at wrong char"); Assert.AreEqual(1, aslist[1].Range.Start.Line, "Edit 1 starts at wrong line"); Assert.AreEqual(21, aslist[1].Range.Start.Character, "Edit 1 starts at wrong char"); Assert.AreEqual(2, aslist[2].Range.Start.Line, "Edit 2 starts at wrong line"); Assert.AreEqual(32, aslist[2].Range.Start.Character, "Edit 2 starts at wrong char"); }
public void TestOutcome() { ISymbolTableManager manager = new FakeSymbolManager(false, false); var provider = new RenameProvider(manager); var result = provider.GetRenameChanges("oink", new Uri("file:///N:/u/l.l"), 2, 22); Assert.IsFalse(provider.Outcome.Error, "no error expected in rename-outcome"); }
public void TestNull() { ISymbolTableManager manager = new FakeSymbolManager(false, true); var provider = new HoverProvider(manager); var result = provider.GetHoverInformation(new Uri("file:///N:/u/l.l"), 0, 10); Assert.IsNull(result); }
public void ReservedWord() { ISymbolTableManager manager = new FakeSymbolManager(false, false); var provider = new RenameProvider(manager); var result = provider.GetRenameChanges("method", new Uri("file:///N:/u/l.l"), 2, 22); Assert.IsTrue(provider.Outcome.Error, "error expected in rename-outcome"); Assert.AreEqual("method" + DafnyLanguageServer.Resources.LoggingMessages.rename_reserved_word, provider.Outcome.Msg); }
public void UnderScoreName() { ISymbolTableManager manager = new FakeSymbolManager(false, false); var provider = new RenameProvider(manager); var result = provider.GetRenameChanges("_abc", new Uri("file:///N:/u/l.l"), 2, 22); Assert.IsTrue(provider.Outcome.Error, "error expected in rename-outcome"); Assert.AreEqual(DafnyLanguageServer.Resources.LoggingMessages.rename_start_with_underscore, provider.Outcome.Msg); }
public void TestNoSymbol() { ISymbolTableManager manager = new FakeSymbolManager(false, true); var provider = new DefinitionsProvider(manager); var result = provider.GetDefinitionLocation(new Uri("file:///N:/u/l.l"), 0, 10); Assert.IsFalse(result.Any()); Assert.AreEqual(DefinitionsOutcome.NotFound, provider.Outcome); }
public void TestRegularAlreadyDefinition() { ISymbolTableManager manager = new FakeSymbolManager(true, false); var provider = new DefinitionsProvider(manager); var result = provider.GetDefinitionLocation(new Uri("file:///N:/u/l.l"), 0, 10); Assert.AreEqual("file:///N:/u/l.l", result.FirstOrDefault().Location.Uri.ToString()); Assert.AreEqual(0, result.FirstOrDefault().Location.Range.Start.Line, "Start Line is not matching"); Assert.AreEqual(10, result.FirstOrDefault().Location.Range.Start.Character, "Start Char is not matching"); Assert.AreEqual(0, result.FirstOrDefault().Location.Range.End.Line, "End Line is not matching"); Assert.AreEqual(10, result.FirstOrDefault().Location.Range.End.Character, "End Char is not matching"); Assert.AreEqual(DefinitionsOutcome.WasAlreadyDefintion, provider.Outcome); }
public void TestRegularNotDefinition() { ISymbolTableManager manager = new FakeSymbolManager(false, false); var provider = new DefinitionsProvider(manager); // note: params do not matter. the fake returns a fixed symbol and does not respect the position. those methods are tested within the symbol table tests. var result = provider.GetDefinitionLocation(new Uri("file:///N:/u/l.l"), 0, 10); Assert.AreEqual("file:///N:/u/l.l", result.FirstOrDefault().Location.Uri.ToString()); Assert.AreEqual(0, result.FirstOrDefault().Location.Range.Start.Line, "Start Line is not matching"); Assert.AreEqual(10, result.FirstOrDefault().Location.Range.Start.Character, "Start Char is not matching"); Assert.AreEqual(0, result.FirstOrDefault().Location.Range.End.Line, "End Line is not matching"); Assert.AreEqual(10, result.FirstOrDefault().Location.Range.End.Character, "End Char is not matching"); Assert.AreEqual(DefinitionsOutcome.Success, provider.Outcome); }
public void TestRegular2() { ISymbolTableManager manager = new FakeSymbolManager(true, false); var provider = new HoverProvider(manager); var result = provider.GetHoverInformation(new Uri("file:///N:/u/l.l"), 0, 10); Assert.AreEqual(0, result.Range.Start.Line, "Start Line is not matching"); Assert.AreEqual(10, result.Range.Start.Character, "Start Char is not matching"); Assert.AreEqual(0, result.Range.End.Line, "End Line is not matching"); Assert.AreEqual(18, result.Range.End.Character, "End Char is not matching"); Console.WriteLine(result.Contents.MarkupContent.Value); string textExpectation = " **`barapapa`** *(line 1, l.l)*\n" + "* **Type:** N/A\n" + "* **Kind:** RootNode\n" + "* **Scope:** `_programRootNode`\n" + "* **Declaration:** This symbol is the declaration."; string actual = result.Contents.MarkupContent.Value.Replace("N:\\u\\l.l", "l.l"); Assert.AreEqual(textExpectation, actual, "Markup Content does not match"); }