Skip to content

Commit

Permalink
Merge pull request #74 from lundmikkel/master
Browse files Browse the repository at this point in the history
Fixes IsStatic() extension method.
  • Loading branch information
JakeGinnivan committed May 13, 2016
2 parents a6d1be3 + bc2b594 commit 6a0a695
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
100 changes: 100 additions & 0 deletions TestStack.ConventionTests.Tests/ConventionData/TypeExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
namespace TestStack.ConventionTests.Tests.TestConventions
{
using NUnit.Framework;

using TestStack.ConventionTests.ConventionData;


[TestFixture]
public class TypeExtensionsTests
{
#region IsStatic

[Test]
public void IsStatic_StaticClass_True()
{
// Arrange
var type = typeof(StaticClass);

// Act
var isStatic = type.IsStatic();

// Assert
Assert.That(isStatic, Is.True);
}

[Test]
public void IsStatic_SealedClass_False()
{
// Arrange
var type = typeof(SealedClass);

// Act
var isStatic = type.IsStatic();

// Assert
Assert.That(isStatic, Is.False);
}

[Test]
public void IsStatic_NonStaticClass_False()
{
// Arrange
var type = typeof(NonStaticClass);

// Act
var isStatic = type.IsStatic();

// Assert
Assert.That(isStatic, Is.False);
}

[Test]
public void IsStatic_AbstractClass_False()
{
// Arrange
var type = typeof(AbstractClass);

// Act
var isStatic = type.IsStatic();

// Assert
Assert.That(isStatic, Is.False);
}

[Test]
public void IsStatic_Interface_False()
{
// Arrange
var type = typeof(IInterface);

// Act
var isStatic = type.IsStatic();

// Assert
Assert.That(isStatic, Is.False);
}

[Test]
public void IsStatic_SimpleType_False()
{
// Arrange
var type = typeof(int);

// Act
var isStatic = type.IsStatic();

// Assert
Assert.That(isStatic, Is.False);
}


private class NonStaticClass {}
private sealed class SealedClass {}
private static class StaticClass {}
private abstract class AbstractClass {}
private interface IInterface {}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="TestConventions\CollectionsRelationsConvention.cs" />
<Compile Include="ConventionData\TypeExtensionsTests.cs" />
<Compile Include="TypeBasedConventions.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion TestStack.ConventionTests/ConventionData/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static bool IsEnum(this Type type)

public static bool IsStatic(this Type type)
{
return type.IsClass && !(type.IsSealed && type.IsAbstract);
return type.IsClass && type.IsSealed && type.IsAbstract;
}

public static bool IsCompilerGenerated(this Type type)
Expand Down

0 comments on commit 6a0a695

Please sign in to comment.