Skip to content

Commit 6a0a695

Browse files
committed
Merge pull request #74 from lundmikkel/master
Fixes IsStatic() extension method.
2 parents a6d1be3 + bc2b594 commit 6a0a695

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
namespace TestStack.ConventionTests.Tests.TestConventions
2+
{
3+
using NUnit.Framework;
4+
5+
using TestStack.ConventionTests.ConventionData;
6+
7+
8+
[TestFixture]
9+
public class TypeExtensionsTests
10+
{
11+
#region IsStatic
12+
13+
[Test]
14+
public void IsStatic_StaticClass_True()
15+
{
16+
// Arrange
17+
var type = typeof(StaticClass);
18+
19+
// Act
20+
var isStatic = type.IsStatic();
21+
22+
// Assert
23+
Assert.That(isStatic, Is.True);
24+
}
25+
26+
[Test]
27+
public void IsStatic_SealedClass_False()
28+
{
29+
// Arrange
30+
var type = typeof(SealedClass);
31+
32+
// Act
33+
var isStatic = type.IsStatic();
34+
35+
// Assert
36+
Assert.That(isStatic, Is.False);
37+
}
38+
39+
[Test]
40+
public void IsStatic_NonStaticClass_False()
41+
{
42+
// Arrange
43+
var type = typeof(NonStaticClass);
44+
45+
// Act
46+
var isStatic = type.IsStatic();
47+
48+
// Assert
49+
Assert.That(isStatic, Is.False);
50+
}
51+
52+
[Test]
53+
public void IsStatic_AbstractClass_False()
54+
{
55+
// Arrange
56+
var type = typeof(AbstractClass);
57+
58+
// Act
59+
var isStatic = type.IsStatic();
60+
61+
// Assert
62+
Assert.That(isStatic, Is.False);
63+
}
64+
65+
[Test]
66+
public void IsStatic_Interface_False()
67+
{
68+
// Arrange
69+
var type = typeof(IInterface);
70+
71+
// Act
72+
var isStatic = type.IsStatic();
73+
74+
// Assert
75+
Assert.That(isStatic, Is.False);
76+
}
77+
78+
[Test]
79+
public void IsStatic_SimpleType_False()
80+
{
81+
// Arrange
82+
var type = typeof(int);
83+
84+
// Act
85+
var isStatic = type.IsStatic();
86+
87+
// Assert
88+
Assert.That(isStatic, Is.False);
89+
}
90+
91+
92+
private class NonStaticClass {}
93+
private sealed class SealedClass {}
94+
private static class StaticClass {}
95+
private abstract class AbstractClass {}
96+
private interface IInterface {}
97+
98+
#endregion
99+
}
100+
}

TestStack.ConventionTests.Tests/TestStack.ConventionTests.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<DependentUpon>Resources.resx</DependentUpon>
7272
</Compile>
7373
<Compile Include="TestConventions\CollectionsRelationsConvention.cs" />
74+
<Compile Include="ConventionData\TypeExtensionsTests.cs" />
7475
<Compile Include="TypeBasedConventions.cs" />
7576
</ItemGroup>
7677
<ItemGroup>

TestStack.ConventionTests/ConventionData/TypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static bool IsEnum(this Type type)
2222

2323
public static bool IsStatic(this Type type)
2424
{
25-
return type.IsClass && !(type.IsSealed && type.IsAbstract);
25+
return type.IsClass && type.IsSealed && type.IsAbstract;
2626
}
2727

2828
public static bool IsCompilerGenerated(this Type type)

0 commit comments

Comments
 (0)