Remove use of `Assert.DoesNotThrow()`

- no longer in xunit 😃
This commit is contained in:
Doug Bunting 2014-12-11 15:51:15 -08:00
parent 3dfcc884fe
commit 3e26142de1
10 changed files with 38 additions and 44 deletions

View File

@ -22,8 +22,8 @@ namespace Microsoft.AspNet.Mvc
var context = new ActionContext(httpContext.Object, routeData, actionDescriptor);
// Act & Assert
Assert.DoesNotThrow(() => emptyResult.ExecuteResult(context));
// Act & Assert (does not throw)
emptyResult.ExecuteResult(context);
}
}
}

View File

@ -55,7 +55,9 @@ namespace Microsoft.AspNet.Mvc
Assert.Empty(values.ActionsMatchingActionConstraints);
Assert.Empty(values.FinalMatches);
Assert.Null(values.SelectedAction);
Assert.DoesNotThrow(() => values.Summary);
// (does not throw)
Assert.NotEmpty(values.Summary);
}
[Fact]
@ -146,7 +148,9 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal<ActionDescriptor>(actions, values.ActionsMatchingActionConstraints);
Assert.Equal<ActionDescriptor>(actions, values.FinalMatches);
Assert.Null(values.SelectedAction);
Assert.DoesNotThrow(() => values.Summary);
// (does not throw)
Assert.NotEmpty(values.Summary);
}
[Fact]

View File

@ -40,8 +40,8 @@ namespace Microsoft.AspNet.Mvc.Core.Test
var controller = new Object();
// Act + Assert
Assert.DoesNotThrow(() => factory.ReleaseController(controller));
// Act + Assert (does not throw)
factory.ReleaseController(controller);
}
private class MyController : Controller

View File

@ -37,8 +37,8 @@ namespace Microsoft.AspNet.Mvc
services.Setup(o => o.GetService(typeof(MvcMarkerService)))
.Returns(expectedOutput);
// Act & Assert
Assert.DoesNotThrow(() => MvcServicesHelper.ThrowIfMvcNotRegistered(services.Object));
// Act & Assert (does not throw)
MvcServicesHelper.ThrowIfMvcNotRegistered(services.Object);
}
}
}

View File

@ -15,8 +15,8 @@ namespace Microsoft.AspNet.Mvc.Internal
// Arrange
var task = Task.FromResult(0);
// Act and Assert
Assert.DoesNotThrow(() => TaskHelper.WaitAndThrowIfFaulted(task));
// Act and Assert (does not throw)
TaskHelper.WaitAndThrowIfFaulted(task);
}
[Fact]

View File

@ -22,17 +22,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
// Arrange
var provider = TestHelper.CreateServices("AutofacWebSite");
Action<IApplicationBuilder> app = new Startup().Configure;
HttpResponseMessage response = null;
// Act & Assert
await Assert.DoesNotThrowAsync(async () =>
{
// This essentially calls into the Startup.Configuration method
var server = TestServer.Create(provider, app);
// Act & Assert (does not throw)
// This essentially calls into the Startup.Configuration method
var server = TestServer.Create(provider, app);
// Make a request to start resolving DI pieces
response = await server.CreateClient().GetAsync(url);
});
// Make a request to start resolving DI pieces
var response = await server.CreateClient().GetAsync(url);
var actualResponseBody = await response.Content.ReadAsStringAsync();
Assert.Equal(expectedResponseBody, actualResponseBody);

View File

@ -214,10 +214,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var validationContext = GetModelValidationContext(model, type);
// Act
Assert.DoesNotThrow(() =>
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty)
);
// Act (does not throw)
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
// Assert
var actualErrors = new Dictionary<string, string>();
@ -278,12 +276,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var validationContext = GetModelValidationContext(input, type, excludedTypes);
// Act & Assert
Assert.DoesNotThrow(
() =>
{
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
});
// Act & Assert (does not throw)
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
Assert.True(validationContext.ModelState.IsValid);
}
@ -312,10 +306,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
var model = new Address() { Street = "Microsoft Way" };
var validationContext = GetModelValidationContext(model, model.GetType());
// Act
Assert.DoesNotThrow(() =>
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty)
);
// Act (does not throw)
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
// Assert
Assert.Contains("Street", validationContext.ModelState.Keys);
@ -336,9 +328,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
};
var validationContext = GetModelValidationContext(instance, typeof(TypeThatOverridesEquals[]));
// Act & Assert
Assert.DoesNotThrow(
() => new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty));
// Act & Assert (does not throw)
new DefaultBodyModelValidator().Validate(validationContext, keyPrefix: string.Empty);
}
private ModelValidationContext GetModelValidationContext(

View File

@ -30,7 +30,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
var t1 = new TypeThatOverridesEquals();
var t2 = new TypeThatOverridesEquals();
Assert.DoesNotThrow(() => ReferenceEqualityComparer.Instance.Equals(t1, t2));
// Act & Assert (does not throw)
ReferenceEqualityComparer.Instance.Equals(t1, t2);
}
[Fact]
@ -58,7 +59,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void GetHashCode_DoesNotThrowForNull()
{
var comparer = ReferenceEqualityComparer.Instance;
Assert.DoesNotThrow(() => comparer.GetHashCode(null));
// Act & Assert (does not throw)
comparer.GetHashCode(null);
}
private class TypeThatOverridesEquals

View File

@ -522,9 +522,9 @@ namespace Microsoft.AspNet.Mvc.Razor
await page.ExecuteAsync();
page.IsLayoutBeingRendered = true;
// Assert
// Assert (does not throw)
var renderAsyncDelegate = page.SectionWriters["test-section"];
await Assert.DoesNotThrowAsync(() => renderAsyncDelegate(TextWriter.Null));
await renderAsyncDelegate(TextWriter.Null);
}
[Fact]

View File

@ -208,9 +208,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
ViewContext = viewContext,
};
// Act & Assert
// Act & Assert (does not throw)
// Tag helper would throw an NRE if it used Generator value.
await Assert.DoesNotThrowAsync(() => tagHelper.ProcessAsync(tagHelperContext, output));
await tagHelper.ProcessAsync(tagHelperContext, output);
}
[Theory]
@ -247,9 +247,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
Value = value,
};
// Act & Assert
// Act & Assert (does not throw)
// 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);
}
}
}