Remove use of `Assert.DoesNotThrow()`
- no longer in xunit 😃
This commit is contained in:
parent
3dfcc884fe
commit
3e26142de1
|
|
@ -22,8 +22,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
var context = new ActionContext(httpContext.Object, routeData, actionDescriptor);
|
var context = new ActionContext(httpContext.Object, routeData, actionDescriptor);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert (does not throw)
|
||||||
Assert.DoesNotThrow(() => emptyResult.ExecuteResult(context));
|
emptyResult.ExecuteResult(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +55,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
Assert.Empty(values.ActionsMatchingActionConstraints);
|
Assert.Empty(values.ActionsMatchingActionConstraints);
|
||||||
Assert.Empty(values.FinalMatches);
|
Assert.Empty(values.FinalMatches);
|
||||||
Assert.Null(values.SelectedAction);
|
Assert.Null(values.SelectedAction);
|
||||||
Assert.DoesNotThrow(() => values.Summary);
|
|
||||||
|
// (does not throw)
|
||||||
|
Assert.NotEmpty(values.Summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -146,7 +148,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
Assert.Equal<ActionDescriptor>(actions, values.ActionsMatchingActionConstraints);
|
Assert.Equal<ActionDescriptor>(actions, values.ActionsMatchingActionConstraints);
|
||||||
Assert.Equal<ActionDescriptor>(actions, values.FinalMatches);
|
Assert.Equal<ActionDescriptor>(actions, values.FinalMatches);
|
||||||
Assert.Null(values.SelectedAction);
|
Assert.Null(values.SelectedAction);
|
||||||
Assert.DoesNotThrow(() => values.Summary);
|
|
||||||
|
// (does not throw)
|
||||||
|
Assert.NotEmpty(values.Summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
|
|
||||||
var controller = new Object();
|
var controller = new Object();
|
||||||
|
|
||||||
// Act + Assert
|
// Act + Assert (does not throw)
|
||||||
Assert.DoesNotThrow(() => factory.ReleaseController(controller));
|
factory.ReleaseController(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyController : Controller
|
private class MyController : Controller
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
services.Setup(o => o.GetService(typeof(MvcMarkerService)))
|
services.Setup(o => o.GetService(typeof(MvcMarkerService)))
|
||||||
.Returns(expectedOutput);
|
.Returns(expectedOutput);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert (does not throw)
|
||||||
Assert.DoesNotThrow(() => MvcServicesHelper.ThrowIfMvcNotRegistered(services.Object));
|
MvcServicesHelper.ThrowIfMvcNotRegistered(services.Object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,8 +15,8 @@ namespace Microsoft.AspNet.Mvc.Internal
|
||||||
// Arrange
|
// Arrange
|
||||||
var task = Task.FromResult(0);
|
var task = Task.FromResult(0);
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert (does not throw)
|
||||||
Assert.DoesNotThrow(() => TaskHelper.WaitAndThrowIfFaulted(task));
|
TaskHelper.WaitAndThrowIfFaulted(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -22,17 +22,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||||
// Arrange
|
// Arrange
|
||||||
var provider = TestHelper.CreateServices("AutofacWebSite");
|
var provider = TestHelper.CreateServices("AutofacWebSite");
|
||||||
Action<IApplicationBuilder> app = new Startup().Configure;
|
Action<IApplicationBuilder> app = new Startup().Configure;
|
||||||
HttpResponseMessage response = null;
|
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert (does not throw)
|
||||||
await Assert.DoesNotThrowAsync(async () =>
|
// This essentially calls into the Startup.Configuration method
|
||||||
{
|
var server = TestServer.Create(provider, app);
|
||||||
// This essentially calls into the Startup.Configuration method
|
|
||||||
var server = TestServer.Create(provider, app);
|
|
||||||
|
|
||||||
// Make a request to start resolving DI pieces
|
// Make a request to start resolving DI pieces
|
||||||
response = await server.CreateClient().GetAsync(url);
|
var response = await server.CreateClient().GetAsync(url);
|
||||||
});
|
|
||||||
|
|
||||||
var actualResponseBody = await response.Content.ReadAsStringAsync();
|
var actualResponseBody = await response.Content.ReadAsStringAsync();
|
||||||
Assert.Equal(expectedResponseBody, actualResponseBody);
|
Assert.Equal(expectedResponseBody, actualResponseBody);
|
||||||
|
|
|
||||||
|
|
@ -214,10 +214,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
// Arrange
|
// Arrange
|
||||||
var validationContext = GetModelValidationContext(model, type);
|
var validationContext = GetModelValidationContext(model, type);
|
||||||
|
|
||||||
// Act
|
// Act (does not throw)
|
||||||
Assert.DoesNotThrow(() =>
|
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
|
||||||
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var actualErrors = new Dictionary<string, string>();
|
var actualErrors = new Dictionary<string, string>();
|
||||||
|
|
@ -278,12 +276,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
// Arrange
|
// Arrange
|
||||||
var validationContext = GetModelValidationContext(input, type, excludedTypes);
|
var validationContext = GetModelValidationContext(input, type, excludedTypes);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert (does not throw)
|
||||||
Assert.DoesNotThrow(
|
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
|
||||||
() =>
|
|
||||||
{
|
|
||||||
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
|
|
||||||
});
|
|
||||||
Assert.True(validationContext.ModelState.IsValid);
|
Assert.True(validationContext.ModelState.IsValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,10 +306,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
var model = new Address() { Street = "Microsoft Way" };
|
var model = new Address() { Street = "Microsoft Way" };
|
||||||
var validationContext = GetModelValidationContext(model, model.GetType());
|
var validationContext = GetModelValidationContext(model, model.GetType());
|
||||||
|
|
||||||
// Act
|
// Act (does not throw)
|
||||||
Assert.DoesNotThrow(() =>
|
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
|
||||||
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Contains("Street", validationContext.ModelState.Keys);
|
Assert.Contains("Street", validationContext.ModelState.Keys);
|
||||||
|
|
@ -336,9 +328,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
};
|
};
|
||||||
var validationContext = GetModelValidationContext(instance, typeof(TypeThatOverridesEquals[]));
|
var validationContext = GetModelValidationContext(instance, typeof(TypeThatOverridesEquals[]));
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert (does not throw)
|
||||||
Assert.DoesNotThrow(
|
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
|
||||||
() => new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModelValidationContext GetModelValidationContext(
|
private ModelValidationContext GetModelValidationContext(
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
var t1 = new TypeThatOverridesEquals();
|
var t1 = new TypeThatOverridesEquals();
|
||||||
var t2 = new TypeThatOverridesEquals();
|
var t2 = new TypeThatOverridesEquals();
|
||||||
|
|
||||||
Assert.DoesNotThrow(() => ReferenceEqualityComparer.Instance.Equals(t1, t2));
|
// Act & Assert (does not throw)
|
||||||
|
ReferenceEqualityComparer.Instance.Equals(t1, t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -58,7 +59,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
public void GetHashCode_DoesNotThrowForNull()
|
public void GetHashCode_DoesNotThrowForNull()
|
||||||
{
|
{
|
||||||
var comparer = ReferenceEqualityComparer.Instance;
|
var comparer = ReferenceEqualityComparer.Instance;
|
||||||
Assert.DoesNotThrow(() => comparer.GetHashCode(null));
|
|
||||||
|
// Act & Assert (does not throw)
|
||||||
|
comparer.GetHashCode(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TypeThatOverridesEquals
|
private class TypeThatOverridesEquals
|
||||||
|
|
|
||||||
|
|
@ -522,9 +522,9 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
await page.ExecuteAsync();
|
await page.ExecuteAsync();
|
||||||
page.IsLayoutBeingRendered = true;
|
page.IsLayoutBeingRendered = true;
|
||||||
|
|
||||||
// Assert
|
// Assert (does not throw)
|
||||||
var renderAsyncDelegate = page.SectionWriters["test-section"];
|
var renderAsyncDelegate = page.SectionWriters["test-section"];
|
||||||
await Assert.DoesNotThrowAsync(() => renderAsyncDelegate(TextWriter.Null));
|
await renderAsyncDelegate(TextWriter.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -208,9 +208,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
|
||||||
ViewContext = viewContext,
|
ViewContext = viewContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert (does not throw)
|
||||||
// Tag helper would throw an NRE if it used Generator value.
|
// Tag helper would throw an NRE if it used Generator value.
|
||||||
await Assert.DoesNotThrowAsync(() => tagHelper.ProcessAsync(tagHelperContext, output));
|
await tagHelper.ProcessAsync(tagHelperContext, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
@ -247,9 +247,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
|
||||||
Value = value,
|
Value = value,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert (does not throw)
|
||||||
// Tag helper would throw an NRE if it used ViewContext or Generator values.
|
// Tag helper would throw an NRE if it used ViewContext or Generator values.
|
||||||
await Assert.DoesNotThrowAsync(() => tagHelper.ProcessAsync(tagHelperContext, output));
|
await tagHelper.ProcessAsync(tagHelperContext, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue