Run unit tests during builds

- add "test" command
- use latest (forked) XUnit packages
  update package references
  [PropertyData] -> [MemberData]
  Xunit.Extensions -> Xunit or Xunit.SDK
  Moq now available for .NET 4.5 only
- delete a couple of unit tests checking for ArgumentNullException
- provide TestCommon classes in Razor and Razor.Host test projects
- make ReplaceCulture internal because it's a shared source
This commit is contained in:
dougbu 2014-03-17 16:28:25 -07:00
parent f8179f03e4
commit ed1b2ddcc3
12 changed files with 69 additions and 43 deletions

View File

@ -4,15 +4,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
{ {
public class ComplexModelDtoResultTest public class ComplexModelDtoResultTest
{ {
[Fact]
public void Constructor_ThrowsIfValidationNodeIsNull()
{
// Act & assert
ExceptionAssert.ThrowsArgumentNull(
() => new ComplexModelDtoResult("some string", validationNode: null),
"validationNode");
}
[Fact] [Fact]
public void Constructor_SetsProperties() public void Constructor_SetsProperties()
{ {

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Xunit; using Xunit;
using Xunit.Extensions;
namespace Microsoft.AspNet.Mvc.ModelBinding.Internal.Test namespace Microsoft.AspNet.Mvc.ModelBinding.Internal.Test
{ {
@ -50,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal.Test
} }
[Theory] [Theory]
[PropertyData("TypesWithValues")] [MemberData("TypesWithValues")]
public void IsCompatibleWithReturnsTrue_IfValueIsAssignable(Type type, object value) public void IsCompatibleWithReturnsTrue_IfValueIsAssignable(Type type, object value)
{ {
// Act // Act

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Moq; using Moq;
using Xunit; using Xunit;
using Xunit.Extensions;
namespace Microsoft.AspNet.Mvc.ModelBinding.Test namespace Microsoft.AspNet.Mvc.ModelBinding.Test
{ {

View File

@ -4,7 +4,6 @@ using System.Linq;
using Moq; using Moq;
using Moq.Protected; using Moq.Protected;
using Xunit; using Xunit;
using Xunit.Extensions;
namespace Microsoft.AspNet.Mvc.ModelBinding namespace Microsoft.AspNet.Mvc.ModelBinding
{ {
@ -58,7 +57,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
} }
[Theory] [Theory]
[PropertyData("ValidateSetsMemberNamePropertyDataSet")] [MemberData("ValidateSetsMemberNamePropertyDataSet")]
public void ValidateSetsMemberNamePropertyOfValidationContextForProperties(ModelMetadata metadata, string expectedMemberName) public void ValidateSetsMemberNamePropertyOfValidationContextForProperties(ModelMetadata metadata, string expectedMemberName)
{ {
// Arrange // Arrange

View File

@ -7,15 +7,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{ {
private readonly DataAnnotationsModelMetadataProvider _metadataProvider = new DataAnnotationsModelMetadataProvider(); private readonly DataAnnotationsModelMetadataProvider _metadataProvider = new DataAnnotationsModelMetadataProvider();
[Fact]
public void ConstructorGuards()
{
// Act and Assert
ExceptionAssert.ThrowsArgumentNull(
() => new ErrorModelValidator(errorMessage: null),
"errorMessage");
}
[Fact] [Fact]
public void ValidateThrowsException() public void ValidateThrowsException()
{ {

View File

@ -5,14 +5,21 @@
"Microsoft.AspNet.PipelineCore": "0.1-alpha-*", "Microsoft.AspNet.PipelineCore": "0.1-alpha-*",
"Microsoft.AspNet.Mvc.ModelBinding" : "", "Microsoft.AspNet.Mvc.ModelBinding" : "",
"TestCommon" : "", "TestCommon" : "",
"Moq": "4.0.10827", "Xunit.KRunner": "0.1-alpha-*",
"Xunit": "1.9.1", "xunit.abstractions": "2.0.0-aspnet-*",
"Xunit.extensions": "1.9.1" "xunit.assert": "2.0.0-aspnet-*",
"xunit.core": "2.0.0-aspnet-*",
"xunit.execution": "2.0.0-aspnet-*"
},
"commands": {
"test": "Xunit.KRunner"
}, },
"configurations": { "configurations": {
"net45": { "net45": {
dependencies: { dependencies: {
"Moq": "4.2.1312.1622",
"System.ComponentModel.DataAnnotations": "", "System.ComponentModel.DataAnnotations": "",
"System.Reflection": "",
"System.Runtime.Serialization": "" "System.Runtime.Serialization": ""
} }
}, },

View File

@ -3,11 +3,22 @@
"dependencies": { "dependencies": {
"Microsoft.AspNet.Razor" : "0.1-alpha-*", "Microsoft.AspNet.Razor" : "0.1-alpha-*",
"Microsoft.AspNet.Mvc.Razor.Host" : "", "Microsoft.AspNet.Mvc.Razor.Host" : "",
"Moq": "4.0.10827", "TestCommon" : "",
"Xunit": "1.9.1", "Xunit.KRunner": "0.1-alpha-*",
"Xunit.extensions": "1.9.1" "xunit.abstractions": "2.0.0-aspnet-*",
"xunit.assert": "2.0.0-aspnet-*",
"xunit.core": "2.0.0-aspnet-*",
"xunit.execution": "2.0.0-aspnet-*"
},
"commands": {
"test": "Xunit.KRunner"
}, },
"configurations": { "configurations": {
"net45": { } "net45": {
"dependencies": {
"Moq": "4.2.1312.1622",
"System.Reflection": ""
}
}
} }
} }

View File

@ -10,7 +10,7 @@ using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.Net.Runtime; using Microsoft.Net.Runtime;
using Moq; using Moq;
using Xunit.Extensions; using Xunit;
namespace Microsoft.AspNet.Mvc.Razor.Test namespace Microsoft.AspNet.Mvc.Razor.Test
{ {

View File

@ -5,11 +5,22 @@
"Microsoft.AspNet.Razor": "0.1-alpha-*", "Microsoft.AspNet.Razor": "0.1-alpha-*",
"Microsoft.AspNet.Mvc.Razor" : "", "Microsoft.AspNet.Mvc.Razor" : "",
"Microsoft.AspNet.Mvc.Razor.Host" : "", "Microsoft.AspNet.Mvc.Razor.Host" : "",
"Moq": "4.0.10827", "TestCommon" : "",
"Xunit": "1.9.1", "Xunit.KRunner": "0.1-alpha-*",
"Xunit.extensions": "1.9.1" "xunit.abstractions": "2.0.0-aspnet-*",
"xunit.assert": "2.0.0-aspnet-*",
"xunit.core": "2.0.0-aspnet-*",
"xunit.execution": "2.0.0-aspnet-*"
},
"commands": {
"test": "Xunit.KRunner"
}, },
"configurations": { "configurations": {
"net45": { } "net45": {
"dependencies": {
"Moq": "4.2.1312.1622",
"System.Reflection": ""
}
}
} }
} }

View File

@ -5,11 +5,21 @@
"Microsoft.AspNet.PipelineCore": "0.1-alpha-*", "Microsoft.AspNet.PipelineCore": "0.1-alpha-*",
"Microsoft.AspNet.Mvc.Rendering" : "", "Microsoft.AspNet.Mvc.Rendering" : "",
"TestCommon" : "", "TestCommon" : "",
"Moq": "4.0.10827", "Xunit.KRunner": "0.1-alpha-*",
"Xunit": "1.9.1", "xunit.abstractions": "2.0.0-aspnet-*",
"Xunit.extensions": "1.9.1" "xunit.assert": "2.0.0-aspnet-*",
"xunit.core": "2.0.0-aspnet-*",
"xunit.execution": "2.0.0-aspnet-*"
},
"commands": {
"test": "Xunit.KRunner"
}, },
"configurations": { "configurations": {
"net45": { } "net45": {
"dependencies": {
"Moq": "4.2.1312.1622",
"System.Reflection": ""
}
}
} }
} }

View File

@ -2,6 +2,7 @@
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using Xunit.Sdk;
namespace Microsoft.AspNet.Mvc namespace Microsoft.AspNet.Mvc
{ {
@ -9,7 +10,7 @@ namespace Microsoft.AspNet.Mvc
/// Replaces the current culture and UI culture for the test. /// Replaces the current culture and UI culture for the test.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class ReplaceCultureAttribute : Xunit.BeforeAfterTestAttribute internal class ReplaceCultureAttribute : BeforeAfterTestAttribute
{ {
private const string _defaultCultureName = "en-GB"; private const string _defaultCultureName = "en-GB";
private const string _defaultUICultureName = "en-US"; private const string _defaultUICultureName = "en-US";

View File

@ -1,10 +1,17 @@
{ {
"shared": "*.cs", "shared": "*.cs",
"dependencies": { "dependencies": {
"Xunit": "1.9.1", "xunit.abstractions": "2.0.0-aspnet-*",
"Xunit.extensions": "1.9.1" "xunit.assert": "2.0.0-aspnet-*",
"xunit.core": "2.0.0-aspnet-*",
"xunit.execution": "2.0.0-aspnet-*"
}, },
"configurations": { "configurations": {
"net45": { } "net45": {
"dependencies": {
"Moq": "4.2.1312.1622",
"System.Reflection": ""
}
}
} }
} }