Update usage of TestSink
This commit is contained in:
parent
e6be423c33
commit
c35030267c
|
|
@ -45,8 +45,8 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
|||
|
||||
// Assert
|
||||
Assert.Empty(sink.Scopes);
|
||||
Assert.Single(sink.Writes);
|
||||
Assert.Equal(expectedMessage, sink.Writes[0].State?.ToString());
|
||||
var write = Assert.Single(sink.Writes);
|
||||
Assert.Equal(expectedMessage, write.State?.ToString());
|
||||
}
|
||||
|
||||
private MvcRouteHandler CreateMvcRouteHandler(
|
||||
|
|
|
|||
|
|
@ -301,8 +301,8 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
|||
|
||||
// Assert
|
||||
Assert.Empty(sink.Scopes);
|
||||
Assert.Single(sink.Writes);
|
||||
Assert.Equal(expectedMessage, sink.Writes[0].State?.ToString());
|
||||
var write = Assert.Single(sink.Writes);
|
||||
Assert.Equal(expectedMessage, write.State?.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -770,7 +770,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
|||
{
|
||||
new DefaultActionConstraintProvider(),
|
||||
};
|
||||
|
||||
|
||||
var actionSelector = new ActionSelector(
|
||||
actionDescriptorCollectionProvider,
|
||||
GetActionConstraintCache(actionConstraintProviders),
|
||||
|
|
|
|||
|
|
@ -91,8 +91,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
logger.AuthorizationFiltersExecutionPlan(filters);
|
||||
|
||||
// Assert
|
||||
Assert.Single(testSink.Writes);
|
||||
var write = testSink.Writes[0];
|
||||
var write = Assert.Single(testSink.Writes);
|
||||
Assert.Equal(
|
||||
"Execution plan of authorization filters (in the following order): " +
|
||||
$"{authFilter.GetType()}, {asyncAuthFilter.GetType()}, {orderedAuthFilter.GetType()} (Order: -100)",
|
||||
|
|
@ -138,8 +137,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
logger.ResourceFiltersExecutionPlan(filters);
|
||||
|
||||
// Assert
|
||||
Assert.Single(testSink.Writes);
|
||||
var write = testSink.Writes[0];
|
||||
var write = Assert.Single(testSink.Writes);
|
||||
Assert.Equal(
|
||||
"Execution plan of resource filters (in the following order): " +
|
||||
$"{resourceFilter.GetType()}, {asyncResourceFilter.GetType()}, {orderedResourceFilter.GetType()} (Order: -100)",
|
||||
|
|
@ -185,8 +183,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
logger.ActionFiltersExecutionPlan(filters);
|
||||
|
||||
// Assert
|
||||
Assert.Single(testSink.Writes);
|
||||
var write = testSink.Writes[0];
|
||||
var write = Assert.Single(testSink.Writes);
|
||||
Assert.Equal(
|
||||
"Execution plan of action filters (in the following order): " +
|
||||
$"{actionFilter.GetType()}, {asyncActionFilter.GetType()}, {orderedActionFilter.GetType()} (Order: -100)",
|
||||
|
|
@ -232,8 +229,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
logger.ExceptionFiltersExecutionPlan(filters);
|
||||
|
||||
// Assert
|
||||
Assert.Single(testSink.Writes);
|
||||
var write = testSink.Writes[0];
|
||||
var write = Assert.Single(testSink.Writes);
|
||||
Assert.Equal(
|
||||
"Execution plan of exception filters (in the following order): " +
|
||||
$"{exceptionFilter.GetType()}, {asyncExceptionFilter.GetType()}, {orderedExceptionFilter.GetType()} (Order: -100)",
|
||||
|
|
@ -279,8 +275,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
|||
logger.ResultFiltersExecutionPlan(filters);
|
||||
|
||||
// Assert
|
||||
Assert.Single(testSink.Writes);
|
||||
var write = testSink.Writes[0];
|
||||
var write = Assert.Single(testSink.Writes);
|
||||
Assert.Equal(
|
||||
"Execution plan of result filters (in the following order): " +
|
||||
$"{resultFilter.GetType()}, {asyncResultFilter.GetType()}, {orderedResultFilter.GetType()} (Order: -100)",
|
||||
|
|
|
|||
|
|
@ -647,10 +647,12 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
// Act
|
||||
await binder.BindModelAsync(bindingContext);
|
||||
|
||||
var writeList = sink.Writes.ToList();
|
||||
|
||||
// Assert
|
||||
Assert.Equal($"Attempting to bind model of type '{typeof(Person)}' using the name 'someName' in request data ...", sink.Writes[0].State.ToString());
|
||||
Assert.Equal($"Rejected input formatter '{typeof(TestInputFormatter)}' for content type 'application/json'.", sink.Writes[1].State.ToString());
|
||||
Assert.Equal($"Selected input formatter '{typeof(TestInputFormatter)}' for content type 'application/json'.", sink.Writes[2].State.ToString());
|
||||
Assert.Equal($"Attempting to bind model of type '{typeof(Person)}' using the name 'someName' in request data ...", writeList[0].State.ToString());
|
||||
Assert.Equal($"Rejected input formatter '{typeof(TestInputFormatter)}' for content type 'application/json'.", writeList[1].State.ToString());
|
||||
Assert.Equal($"Selected input formatter '{typeof(TestInputFormatter)}' for content type 'application/json'.", writeList[2].State.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
|
@ -193,7 +194,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
// Assert
|
||||
Assert.Equal(ModelBindingResult.Failed(), bindingContext.Result);
|
||||
Assert.Empty(bindingContext.ModelState);
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(2, sink.Writes.Count());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -283,7 +284,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
|
|||
Assert.True(bindingContext.Result.IsModelSet);
|
||||
Assert.Equal(42, bindingContext.Result.Model);
|
||||
Assert.True(bindingContext.ModelState.ContainsKey("theModelName"));
|
||||
Assert.Equal(2, sink.Writes.Count);
|
||||
Assert.Equal(2, sink.Writes.Count());
|
||||
}
|
||||
|
||||
public static TheoryData<Type> BiggerNumericTypes
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|||
Assert.Equal(expectedKey, modelState.Key);
|
||||
var error = Assert.Single(modelState.Value.Errors);
|
||||
Assert.Equal(attribute.FormatErrorMessage(expectedFieldName), error.ErrorMessage);
|
||||
Assert.Equal(4, sink.Writes.Count);
|
||||
Assert.Equal(4, sink.Writes.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
[Fact]
|
||||
public void Init_InvokesComponentsInitInCorrectOrder()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
"head",
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
|
|
@ -72,7 +72,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
[Fact]
|
||||
public async void ProcessAsync_InvokesComponentsProcessAsyncInCorrectOrder()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
"head",
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
|
|
@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
[Fact]
|
||||
public void Init_InvokesTagHelperComponentInit()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
"head",
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
|
|
@ -183,7 +183,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
// Act
|
||||
await testTagHelperComponentTagHelper.ProcessAsync(tagHelperContext, output);
|
||||
|
||||
// Assert
|
||||
// Assert
|
||||
Assert.Equal("Processed1", output.PostContent.GetContent());
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
// Act
|
||||
await testTagHelperComponentTagHelper.ProcessAsync(tagHelperContext, output);
|
||||
|
||||
// Assert
|
||||
// Assert
|
||||
Assert.Equal("Processed0Processed1Processed2", output.PostContent.GetContent());
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
testTagHelperComponentTagHelper.Init(tagHelperContext);
|
||||
|
||||
// Assert
|
||||
Assert.Equal($"Tag helper component '{typeof(TestTagHelperComponent)}' initialized.", sink.Writes[0].State.ToString(), StringComparer.Ordinal);
|
||||
Assert.Equal($"Tag helper component '{typeof(TestTagHelperComponent)}' initialized.", sink.Writes.First().State.ToString(), StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -282,14 +282,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
|
|||
// Act
|
||||
await testTagHelperComponentTagHelper.ProcessAsync(tagHelperContext, output);
|
||||
|
||||
// Assert
|
||||
Assert.Equal($"Tag helper component '{typeof(TestTagHelperComponent)}' processed.", sink.Writes[0].State.ToString(), StringComparer.Ordinal);
|
||||
// Assert
|
||||
Assert.Equal($"Tag helper component '{typeof(TestTagHelperComponent)}' processed.", sink.Writes.First().State.ToString(), StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Init_GetsTagHelperComponentPropertyActivator_FromRequestServices()
|
||||
{
|
||||
// Arrange
|
||||
// Arrange
|
||||
var tagHelperContext = new TagHelperContext(
|
||||
"head",
|
||||
allAttributes: new TagHelperAttributeList(
|
||||
|
|
|
|||
Loading…
Reference in New Issue