Skip to content

Commit

Permalink
Use UT and build script
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Oct 6, 2017
1 parent 85d972b commit e54129c
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 28 deletions.
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ before_build:
- choco install codecov

build:
parallel: true
verbosity: minimal

test_script:
- cd src\Ninject.Test
- OpenCover.Console.exe -oldstyle -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"xunit -nobuild -quiet" -filter:"+[Ninject]*" -output:"..\..\Ninject_coverage.xml"
- OpenCover.Console.exe -oldstyle -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"xunit -configuration Release -nobuild" -filter:"+[Ninject]*" -output:"Ninject_coverage.xml"
- codecov -f "Ninject_coverage.xml"

artifacts:
Expand Down
3 changes: 2 additions & 1 deletion src/Ninject.Test/Integration/ActivationStrategyTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Ninject.Tests.Integration
{
using System;
using System.Linq;
using FluentAssertions;

Expand All @@ -8,7 +9,7 @@
using Ninject.Tests.Fakes;
using Xunit;

public class ActivationStrategyTests
public class ActivationStrategyTests : IDisposable
{
private readonly StandardKernel kernel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
//-------------------------------------------------------------------------------
namespace Ninject.Tests.Integration
{
using System;
using FluentAssertions;
using Ninject.Tests.Fakes;
using Xunit;

public class ConstructorArgumentInBindingConfigurationBuilderTest
public class ConstructorArgumentInBindingConfigurationBuilderTest : IDisposable
{
private readonly StandardKernel kernel;

Expand Down
6 changes: 3 additions & 3 deletions src/Ninject.Test/Integration/ConstructorArgumentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void Dispose()


[Theory]
[MemberData("ConstructorArguments")]
[MemberData(nameof(ConstructorArguments))]
public void ConstructorArgumentsArePassedToFirstLevel(Func<bool, IConstructorArgument> constructorArgument)
{
this.kernel.Bind<IWarrior>().To<Samurai>();
Expand All @@ -103,7 +103,7 @@ public void ConstructorArgumentsArePassedToFirstLevel(Func<bool, IConstructorArg
}

[Theory]
[MemberData("ConstructorArgumentsWithoutShouldInheritArgument")]
[MemberData(nameof(ConstructorArgumentsWithoutShouldInheritArgument))]
public void ConstructorArgumentsAreNotInheritedIfNotSpecified(Func<IConstructorArgument> constructorArgument)
{
this.kernel.Bind<IWarrior>().To<Samurai>();
Expand All @@ -114,7 +114,7 @@ public void ConstructorArgumentsAreNotInheritedIfNotSpecified(Func<IConstructorA
}

[Theory]
[MemberData("ConstructorArguments")]
[MemberData(nameof(ConstructorArguments))]
public void ConstructorArgumentsAreInheritedIfSpecified(Func<bool, IConstructorArgument> constructorArgument)
{
this.kernel.Bind<IWarrior>().To<Samurai>();
Expand Down
2 changes: 1 addition & 1 deletion src/Ninject.Test/Integration/ConstructorSelectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Ninject.Tests.Integration

using Xunit;

public class ConstructorSelectionTests
public class ConstructorSelectionTests : IDisposable
{
private readonly StandardKernel kernel;

Expand Down
3 changes: 2 additions & 1 deletion src/Ninject.Test/Integration/DefaultParameterTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#if !SILVERLIGHT
namespace Ninject.Tests.Integration
{
using System;
using FluentAssertions;
using Ninject.Tests.Fakes;
using Xunit;

public class DefaultParameterTests
public class DefaultParameterTests : IDisposable
{
private readonly StandardKernel kernel;

Expand Down
5 changes: 0 additions & 5 deletions src/Ninject.Test/Unit/CachePruningTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ public class WhenPruneIsCalled
private Cache cache;

public WhenPruneIsCalled()
{
this.SetUp();
}

public void SetUp()
{
this.cachePrunerMock = new Mock<ICachePruner>();
this.bindingConfigurationMock = new Mock<IBindingConfiguration>();
Expand Down
22 changes: 7 additions & 15 deletions src/Ninject.Test/Unit/ExtensionsForMemberInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void GetCustomAttributesExtended()
this.TestGetCustomAttributesExtended("ProtectedProperty");
this.TestGetCustomAttributesExtended("PrivateProperty");
}

[Fact]
public void GetCustomAttributesExtendedForAttributesOnBaseClass()
{
Expand All @@ -57,19 +57,11 @@ public void IndexerHasAttribute()
this.TestIndexerHasAttribute(typeof(InheritedPropertyAttributeTest), typeof(int), typeof(NotInheritedInjectAttribute), false);
}

public void TestIndexerHasAttribute(Type testObjectType, Type indexerType, Type attributeType, bool expectedResult)
private void TestIndexerHasAttribute(Type testObjectType, Type indexerType, Type attributeType, bool expectedResult)
{
#if !WINRT
var propertyInfo =
testObjectType.GetProperties()
.First(pi => pi.Name == "Item" && pi.GetIndexParameters().Single().ParameterType == indexerType);
#else
var propertyInfo =
testObjectType.GetRuntimeProperties()
.First(pi => pi.Name == "Item" && pi.GetIndexParameters()
.Single()
.ParameterType == indexerType);
#endif

var hasInjectAttribute = propertyInfo.HasAttribute(attributeType);

Expand Down Expand Up @@ -130,7 +122,7 @@ private void TestHasAttributeForAttributesOnBaseClass(string propertyName)
this.TestHasAttribute(propertyAttributeClass, propertyName, typeof(NotInheritedInjectAttribute), false);
this.TestHasAttribute(propertyAttributeClass, propertyName, typeof(NamedAttribute), false);
}

private void TestHasAttribute(object testObject, string attributeName, Type attributeType, bool expectedValue)
{
#if !WINRT
Expand All @@ -141,17 +133,17 @@ private void TestHasAttribute(object testObject, string attributeName, Type attr
.GetRuntimeProperties()
.Single(pi => pi.Name == attributeName);
#endif

bool hasAttribute = propertyInfo.HasAttribute(attributeType);

hasAttribute.Should().Be(expectedValue);
}

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true, Inherited = false)]
public class NotInheritedInjectAttribute : InjectAttribute
public sealed class NotInheritedInjectAttribute : InjectAttribute
{
}

public class PropertyAttributeTest
{
[Inject]
Expand Down Expand Up @@ -234,7 +226,7 @@ public override object this[int name]
{
}
}
}
}
}
#endif
}

0 comments on commit e54129c

Please sign in to comment.