提交 b2261f7a 编写于 作者: T Tanner Gooding 提交者: Jared Parsons

This updates the asserts that have api changes

上级 15d8188e
......@@ -492,7 +492,7 @@ public void InvalidPublicKey()
var r = MetadataReference.CreateFromStream(new MemoryStream(TestResources.SymbolsTests.Metadata.InvalidPublicKey, writable: false));
Assert.Equal(CodeAnalysisResources.InMemoryAssembly, r.Display);
Assert.Throws<BadImageFormatException>(((AssemblyMetadata)r.GetMetadata()).GetAssembly);
Assert.Throws<BadImageFormatException>((Func<object>)((AssemblyMetadata)r.GetMetadata()).GetAssembly);
}
}
}
......@@ -174,8 +174,6 @@ public ServerDispatcher(IRequestHandler handler, IDiagnosticListener diagnosticL
Justification = "We intentionally call GC.Collect when anticipate long period on inactivity.")]
public void ListenAndDispatchConnections(string pipeName, TimeSpan? keepAlive, CancellationToken cancellationToken = default(CancellationToken))
{
Debug.Assert(SynchronizationContext.Current == null);
var isKeepAliveDefault = true;
var connectionList = new List<Task<ConnectionData>>();
Task gcTask = null;
......
......@@ -29,7 +29,7 @@ public void TestNoCyclesInFixProviders()
var csharpProviders = providersPerLanguage[LanguageNames.CSharp];
// ExtensionOrderer.CheckForCycles() will throw ArgumentException if cycle is detected.
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(csharpProviders));
ExtensionOrderer.CheckForCycles(csharpProviders);
// ExtensionOrderer.Order() will not throw even if cycle is detected. However, it will
// break the cycle and the resulting order will end up being unpredictable.
......@@ -39,7 +39,7 @@ public void TestNoCyclesInFixProviders()
actualOrder.IndexOf(p => p.Metadata.Name == PredefinedCodeFixProviderNames.RenameTracking));
var vbProviders = providersPerLanguage[LanguageNames.VisualBasic];
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(vbProviders));
ExtensionOrderer.CheckForCycles(vbProviders);
actualOrder = ExtensionOrderer.Order(vbProviders).ToArray();
Assert.True(actualOrder.Length > 0);
Assert.True(actualOrder.IndexOf(p => p.Metadata.Name == PredefinedCodeFixProviderNames.AddUsingOrImport) <
......@@ -58,7 +58,7 @@ public void TestNoCyclesInSuppressionProviders()
var csharpProviders = providersPerLanguage[LanguageNames.CSharp];
// ExtensionOrderer.CheckForCycles() will throw ArgumentException if cycle is detected.
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(csharpProviders));
ExtensionOrderer.CheckForCycles(csharpProviders);
// ExtensionOrderer.Order() will not throw even if cycle is detected. However, it will
// break the cycle and the resulting order will end up being unpredictable.
......@@ -66,7 +66,7 @@ public void TestNoCyclesInSuppressionProviders()
Assert.Equal(1, actualOrder.Length);
var vbProviders = providersPerLanguage[LanguageNames.VisualBasic];
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(vbProviders));
ExtensionOrderer.CheckForCycles(vbProviders);
actualOrder = ExtensionOrderer.Order(vbProviders).ToArray();
Assert.Equal(1, actualOrder.Length);
}
......@@ -83,7 +83,7 @@ public void TestNoCyclesInRefactoringProviders()
var csharpProviders = providersPerLanguage[LanguageNames.CSharp];
// ExtensionOrderer.CheckForCycles() will throw ArgumentException if cycle is detected.
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(csharpProviders));
ExtensionOrderer.CheckForCycles(csharpProviders);
// ExtensionOrderer.Order() will not throw even if cycle is detected. However, it will
// break the cycle and the resulting order will end up being unpredictable.
......@@ -91,9 +91,9 @@ public void TestNoCyclesInRefactoringProviders()
Assert.True(actualOrder.Length > 0);
var vbProviders = providersPerLanguage[LanguageNames.VisualBasic];
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(vbProviders));
ExtensionOrderer.CheckForCycles(vbProviders);
actualOrder = ExtensionOrderer.Order(vbProviders).ToArray();
Assert.True(actualOrder.Length > 0);
}
}
}
\ No newline at end of file
}
......@@ -30,7 +30,7 @@ public void GetBufferTextFromTextContainerDoesNotThrow()
var textContainer = Microsoft.CodeAnalysis.Text.Extensions.TextBufferContainer.From(bufferMock.Object);
Assert.DoesNotThrow(() => Microsoft.CodeAnalysis.Text.Extensions.GetTextBuffer(textContainer));
Microsoft.CodeAnalysis.Text.Extensions.GetTextBuffer(textContainer);
}
}
}
......@@ -143,17 +143,11 @@ protected override void Dispose(bool finalize)
if (exceptions.Count == 1)
{
throw new Xunit.Sdk.AssertException(
"A exception was encountered during execution and trapped by the editor:\r\n" +
exceptions.Single().Message + "\r\n" +
exceptions.Single().StackTrace);
throw exceptions.Single();
}
else if (exceptions.Count > 1)
{
throw new Xunit.Sdk.AssertException(
"More than one exception was encountered during execution and trapped by the editor:\r\n" +
exceptions.First().Message + "\r\n" +
exceptions.First().StackTrace);
throw new AggregateException(exceptions);
}
if (SynchronizationContext.Current != null)
......
......@@ -351,7 +351,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
Dim analyzerReference2 = CreateAnalyzerFileReference("x:\temp.dll")
project = project.AddAnalyzerReference(analyzerReference1)
#If DEBUG Then
Assert.Throws(Of TraceAssertException)(Function() project.AddAnalyzerReference(analyzerReference2))
Debug.Assert(project.AnalyzerReferences.Contains(analyzerReference2))
#End If
End Using
End Sub
......@@ -408,7 +408,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
project = project.AddAnalyzerReference(analyzerReference1)
project = project.AddAnalyzerReference(analyzerReference2)
#If DEBUG Then
Assert.Throws(Of TraceAssertException)(Function() project.AddAnalyzerReference(analyzerReference1))
Debug.Assert(project.AnalyzerReferences.Contains(analyzerReference1))
#End If
End Using
End Sub
......
......@@ -196,7 +196,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename
End If
Assert.Equal(replacementText, newText)
Catch ex As AssertException
Catch ex As XunitException
_failedAssert = True
Throw
End Try
......@@ -212,7 +212,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename
Assert.True(type.HasFlag(reference.Type))
_unassertedRelatedLocations.Remove(reference)
Catch ex As AssertException
Catch ex As XunitException
_failedAssert = True
Throw
End Try
......@@ -241,7 +241,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename
Public Sub AssertReplacementTextInvalid()
Try
Assert.False(_resolution.ReplacementTextValid)
Catch ex As AssertException
Catch ex As XunitException
_failedAssert = True
Throw
End Try
......
......@@ -116,7 +116,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue.UnitTests
<Fact>
Public Sub ComputeDistance_Node()
Dim distance = SyntaxComparer.ComputeDistance(MakeLiteral(101), MakeLiteral(150))
Assert.Equal(1, Math.Round(distance, 2))
Assert.Equal(1.0, Math.Round(distance, 2))
End Sub
<Fact>
......@@ -125,37 +125,37 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue.UnitTests
Nothing,
ImmutableArray.Create(SyntaxFactory.Token(SyntaxKind.StaticKeyword)))
Assert.Equal(1, Math.Round(distance, 2))
Assert.Equal(1.0, Math.Round(distance, 2))
distance = SyntaxComparer.ComputeDistance(
Nothing,
ImmutableArray.Create(MakeLiteral(0)))
Assert.Equal(1, Math.Round(distance, 2))
Assert.Equal(1.0, Math.Round(distance, 2))
distance = SyntaxComparer.ComputeDistance(
Nothing,
SpecializedCollections.EmptyArray(Of SyntaxNode))
Assert.Equal(0, Math.Round(distance, 2))
Assert.Equal(0.0, Math.Round(distance, 2))
distance = SyntaxComparer.ComputeDistance(
SpecializedCollections.EmptyArray(Of SyntaxNode),
Nothing)
Assert.Equal(0, Math.Round(distance, 2))
Assert.Equal(0.0, Math.Round(distance, 2))
distance = SyntaxComparer.ComputeDistance(
Nothing,
SpecializedCollections.EmptyArray(Of SyntaxToken))
Assert.Equal(0, Math.Round(distance, 2))
Assert.Equal(0.0, Math.Round(distance, 2))
distance = SyntaxComparer.ComputeDistance(
SpecializedCollections.EmptyArray(Of SyntaxToken),
Nothing)
Assert.Equal(0, Math.Round(distance, 2))
Assert.Equal(0.0, Math.Round(distance, 2))
End Sub
End Class
End Namespace
......@@ -112,7 +112,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera
afterCaretPoint = New SnapshotPoint(textView.TextSnapshot, afterLine.Start + afterCaret(1))
End If
Assert.Equal(afterCaretPoint, textView.GetCaretPoint(subjectBuffer).Value.Position)
Assert.Equal(Of Integer)(afterCaretPoint, textView.GetCaretPoint(subjectBuffer).Value.Position)
End Using
End Sub
......@@ -155,7 +155,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera
Assert.Equal(EditorFactory.LinesToFullText(text), textView.TextSnapshot.GetText())
' The caret should not have moved
Assert.Equal(caretPosition, textView.GetCaretPoint(subjectBuffer).Value.Position)
Assert.Equal(Of Integer)(caretPosition, textView.GetCaretPoint(subjectBuffer).Value.Position)
End Using
End Sub
......@@ -252,7 +252,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera
End If
Dim caretPosition = view.Caret.Position.VirtualBufferPosition
Assert.Equal(afterCaretPoint, If(caretPosition.IsInVirtualSpace, caretPosition.Position + caretPosition.VirtualSpaces, caretPosition.Position))
Assert.Equal(Of Integer)(afterCaretPoint, If(caretPosition.IsInVirtualSpace, caretPosition.Position + caretPosition.VirtualSpaces, caretPosition.Position))
End Using
End Sub
End Module
......
......@@ -2874,7 +2874,7 @@ End Class
Dim x = 0
End If
Assert.Equal(expectedIndentation, actualIndentation.Value)
Assert.Equal(Of Integer)(expectedIndentation.Value, actualIndentation.Value)
End Sub
''' <param name="indentationLine">0-based. The line number in code to get indentation for.</param>
......@@ -2913,7 +2913,7 @@ End Class
Dim actualIndentation = indenter.GetDesiredIndentation(indentationLineFromBuffer)
If expectedIndentation.HasValue Then
Assert.Equal(expectedIndentation, actualIndentation.Value)
Assert.Equal(Of Integer)(expectedIndentation.Value, actualIndentation.Value)
Else
Assert.Null(actualIndentation)
End If
......
......@@ -97,13 +97,13 @@ End Class").OrderBy(Function(s) s.Span.Span.Start).ToImmutableArray()
Dim second = spans(1)
Assert.Equal(PredefinedErrorTypeNames.Suggestion, first.Tag.ErrorType)
Assert.Equal(VBFeaturesResources.RemoveUnnecessaryImportsDiagnosticTitle, first.Tag.ToolTipContent)
Assert.Equal(79, first.Span.Start)
Assert.Equal(VBFeaturesResources.RemoveUnnecessaryImportsDiagnosticTitle, CType(first.Tag.ToolTipContent, String))
Assert.Equal(Of Integer)(79, first.Span.Start)
Assert.Equal(83, first.Span.Length)
Assert.Equal(PredefinedErrorTypeNames.Suggestion, second.Tag.ErrorType)
Assert.Equal(WorkspacesResources.NameCanBeSimplified, second.Tag.ToolTipContent)
Assert.Equal(221, second.Span.Start)
Assert.Equal(WorkspacesResources.NameCanBeSimplified, CType(second.Tag.ToolTipContent, String))
Assert.Equal(Of Integer)(221, second.Span.Start)
Assert.Equal(5, second.Span.Length)
End Sub
End Class
......
......@@ -219,7 +219,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Dim ruleSet2 = ruleSetManager.GetOrCreateRuleSet(ruleSetPath)
Assert.Equal(expected:=1, actual:=fileChangeService.WatchedFileCount)
Assert.ReferenceEquals(ruleSet1, ruleSet2)
Assert.Same(ruleSet1, ruleSet2)
End Using
Assert.Equal(expected:=0, actual:=fileChangeService.WatchedFileCount)
......
......@@ -39,7 +39,7 @@ public void TestNoCycle1()
var extensions = new List<Lazy<Extension, ExtensionMetadata>>() { d, b, a, c, e };
// ExtensionOrderer.CheckForCycles() will throw ArgumentException if cycle is detected.
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(extensions));
ExtensionOrderer.CheckForCycles(extensions);
var order = ExtensionOrderer.Order(extensions);
VerifyOrder("abcde", order);
}
......@@ -56,7 +56,7 @@ public void TestNoCycle2()
var extensions = new List<Lazy<Extension, ExtensionMetadata>>() { d, b, a, c, e };
// ExtensionOrderer.CheckForCycles() will throw ArgumentException if cycle is detected.
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(extensions));
ExtensionOrderer.CheckForCycles(extensions);
var order = ExtensionOrderer.Order(extensions);
VerifyOrder("edcba", order);
}
......@@ -73,7 +73,7 @@ public void TestNoCycle3()
var extensions = new List<Lazy<Extension, ExtensionMetadata>>() { d, b, a, c, e };
// ExtensionOrderer.CheckForCycles() will throw ArgumentException if cycle is detected.
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(extensions));
ExtensionOrderer.CheckForCycles(extensions);
var order = ExtensionOrderer.Order(extensions);
VerifyOrder("abcde", order);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册