Restore `[Fact]` and `[Theory]` attributes

- removed in 310ab25
This commit is contained in:
Doug Bunting 2016-04-11 10:56:00 -07:00
parent 310ab25347
commit 0ec2a3131f
3 changed files with 22 additions and 5 deletions

View File

@ -10,8 +10,6 @@ using System.Threading.Tasks;
using System.Xml; using System.Xml;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Moq; using Moq;
using Xunit; using Xunit;
@ -52,6 +50,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
public TestLevelOne TestOne { get; set; } public TestLevelOne TestOne { get; set; }
} }
[Theory]
[InlineData("application/xml", true)] [InlineData("application/xml", true)]
[InlineData("application/*", false)] [InlineData("application/*", false)]
[InlineData("*/*", false)] [InlineData("*/*", false)]
@ -86,6 +85,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Equal(expectedCanRead, result); Assert.Equal(expectedCanRead, result);
} }
[Fact]
public void XmlDataContractSerializer_CachesSerializerForType() public void XmlDataContractSerializer_CachesSerializerForType()
{ {
// Arrange // Arrange
@ -129,6 +129,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.True(formatter.SupportedEncodings.Any(i => i.WebName == "utf-16")); Assert.True(formatter.SupportedEncodings.Any(i => i.WebName == "utf-16"));
} }
[Fact]
public async Task ReadAsync_ReadsSimpleTypes() public async Task ReadAsync_ReadsSimpleTypes()
{ {
// Arrange // Arrange
@ -155,6 +156,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Equal(expectedString, model.sampleString); Assert.Equal(expectedString, model.sampleString);
} }
[Fact]
public async Task ReadAsync_ReadsComplexTypes() public async Task ReadAsync_ReadsComplexTypes()
{ {
// Arrange // Arrange
@ -184,6 +186,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Equal(expectedString, model.TestOne.sampleString); Assert.Equal(expectedString, model.TestOne.sampleString);
} }
[Fact]
public async Task ReadAsync_ReadsWhenMaxDepthIsModified() public async Task ReadAsync_ReadsWhenMaxDepthIsModified()
{ {
// Arrange // Arrange
@ -207,6 +210,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Equal(expectedInt, model.SampleInt); Assert.Equal(expectedInt, model.SampleInt);
} }
[Fact]
public async Task ReadAsync_ThrowsOnExceededMaxDepth() public async Task ReadAsync_ThrowsOnExceededMaxDepth()
{ {
// Arrange // Arrange
@ -223,6 +227,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context)); await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context));
} }
[Fact]
public async Task ReadAsync_ThrowsWhenReaderQuotasAreChanged() public async Task ReadAsync_ThrowsWhenReaderQuotasAreChanged()
{ {
// Arrange // Arrange
@ -249,6 +254,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Throws(typeof(ArgumentException), () => formatter.MaxDepth = 0); Assert.Throws(typeof(ArgumentException), () => formatter.MaxDepth = 0);
} }
[Fact]
public async Task ReadAsync_VerifyStreamIsOpenAfterRead() public async Task ReadAsync_VerifyStreamIsOpenAfterRead()
{ {
// Arrange // Arrange
@ -268,6 +274,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.True(context.HttpContext.Request.Body.CanRead); Assert.True(context.HttpContext.Request.Body.CanRead);
} }
[Fact]
public async Task ReadAsync_FallsbackToUTF8_WhenCharSet_NotInContentType() public async Task ReadAsync_FallsbackToUTF8_WhenCharSet_NotInContentType()
{ {
// Arrange // Arrange
@ -291,6 +298,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Contains("utf-16LE", ex.Message); Assert.Contains("utf-16LE", ex.Message);
} }
[Fact]
public async Task ReadAsync_UsesContentTypeCharSet_ToReadStream() public async Task ReadAsync_UsesContentTypeCharSet_ToReadStream()
{ {
// Arrange // Arrange
@ -319,6 +327,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Contains("utf-8", ex.Message); Assert.Contains("utf-8", ex.Message);
} }
[Fact]
public async Task ReadAsync_IgnoresBOMCharacters() public async Task ReadAsync_IgnoresBOMCharacters()
{ {
// Arrange // Arrange
@ -350,6 +359,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Equal(expectedBytes, Encoding.UTF8.GetBytes(model.SampleString)); Assert.Equal(expectedBytes, Encoding.UTF8.GetBytes(model.SampleString));
} }
[Fact]
public async Task ReadAsync_AcceptsUTF16Characters() public async Task ReadAsync_AcceptsUTF16Characters()
{ {
// Arrange // Arrange
@ -387,6 +397,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Equal(expectedString, model.sampleString); Assert.Equal(expectedString, model.sampleString);
} }
[Fact]
public async Task ReadAsync_ThrowsWhenNotConfiguredWithRootName() public async Task ReadAsync_ThrowsWhenNotConfiguredWithRootName()
{ {
// Arrange // Arrange
@ -405,6 +416,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context)); await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context));
} }
[Fact]
public async Task ReadAsync_ReadsWhenConfiguredWithRootName() public async Task ReadAsync_ReadsWhenConfiguredWithRootName()
{ {
// Arrange // Arrange
@ -441,6 +453,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
Assert.Equal(expectedInt, model.SampleInt); Assert.Equal(expectedInt, model.SampleInt);
} }
[Fact]
public async Task ReadAsync_ThrowsWhenNotConfiguredWithKnownTypes() public async Task ReadAsync_ThrowsWhenNotConfiguredWithKnownTypes()
{ {
// Arrange // Arrange
@ -460,6 +473,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context)); await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context));
} }
[Fact]
public async Task ReadAsync_ReadsWhenConfiguredWithKnownTypes() public async Task ReadAsync_ReadsWhenConfiguredWithKnownTypes()
{ {
// Arrange // Arrange

View File

@ -427,8 +427,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
} }
#if !NETCOREAPP1_0 #if !NETCOREAPP1_0
// DataContractSerializer in CoreCLR does not throw if the declared type is different from the type being
// serialized.
[ConditionalFact] [ConditionalFact]
// Mono issue - https://github.com/aspnet/External/issues/18 // Mono issue - https://github.com/aspnet/External/issues/18
[FrameworkSkipCondition(RuntimeFrameworks.Mono)] [FrameworkSkipCondition(RuntimeFrameworks.Mono)]
@ -444,6 +442,8 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml
async () => await formatter.WriteAsync(outputFormatterContext)); async () => await formatter.WriteAsync(outputFormatterContext));
} }
#else #else
// DataContractSerializer in CoreCLR does not throw if the declared type is different from the type being
// serialized.
[Fact] [Fact]
public async Task WriteAsync_SerializesObjectWhenDeclaredTypeIsDifferentFromActualType() public async Task WriteAsync_SerializesObjectWhenDeclaredTypeIsDifferentFromActualType()
{ {

View File

@ -10,7 +10,6 @@ using System.Net.Http.Headers;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Testing.xunit;
using XmlFormattersWebSite; using XmlFormattersWebSite;
using Xunit; using Xunit;
@ -34,6 +33,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
public HttpClient Client { get; } public HttpClient Client { get; }
[Fact]
public async Task ThrowsOnInvalidInput_AndAddsToModelState() public async Task ThrowsOnInvalidInput_AndAddsToModelState()
{ {
// Arrange // Arrange
@ -53,6 +53,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
data); data);
} }
[Fact]
public async Task RequiredDataIsProvided_AndModelIsBound_NoValidationErrors() public async Task RequiredDataIsProvided_AndModelIsBound_NoValidationErrors()
{ {
// Arrange // Arrange
@ -79,6 +80,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
Assert.Empty(modelBindingInfo.ModelStateErrorMessages); Assert.Empty(modelBindingInfo.ModelStateErrorMessages);
} }
// Verifies that the model state has errors related to body model validation.
[Fact]
public async Task DataMissingForRefereneceTypeProperties_AndModelIsBound_AndHasMixedValidationErrors() public async Task DataMissingForRefereneceTypeProperties_AndModelIsBound_AndHasMixedValidationErrors()
{ {
// Arrange // Arrange