diff --git a/TestStack.ConventionTests.Tests/ConventionData/TypeExtensionsTests.cs b/TestStack.ConventionTests.Tests/ConventionData/TypeExtensionsTests.cs new file mode 100644 index 0000000..c5563d1 --- /dev/null +++ b/TestStack.ConventionTests.Tests/ConventionData/TypeExtensionsTests.cs @@ -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 + } +} \ No newline at end of file diff --git a/TestStack.ConventionTests.Tests/TestStack.ConventionTests.Tests.csproj b/TestStack.ConventionTests.Tests/TestStack.ConventionTests.Tests.csproj index 842230f..71dc2b8 100644 --- a/TestStack.ConventionTests.Tests/TestStack.ConventionTests.Tests.csproj +++ b/TestStack.ConventionTests.Tests/TestStack.ConventionTests.Tests.csproj @@ -71,6 +71,7 @@ Resources.resx + diff --git a/TestStack.ConventionTests/ConventionData/TypeExtensions.cs b/TestStack.ConventionTests/ConventionData/TypeExtensions.cs index e92bef7..476577e 100644 --- a/TestStack.ConventionTests/ConventionData/TypeExtensions.cs +++ b/TestStack.ConventionTests/ConventionData/TypeExtensions.cs @@ -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)