-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Empty(Test)Type attributes to contracts.
- Loading branch information
Showing
8 changed files
with
124 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
using Qowaiv; | ||
using Qowaiv.Identifiers; | ||
using Qowaiv.TestTools; | ||
|
||
namespace Benchmarks; | ||
|
||
|
43 changes: 18 additions & 25 deletions
43
specs/Qowaiv.Specs/Diagnostics/Contracts/Conditional_specs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
namespace Diagnostics.Contracts.Conditional_specs; | ||
|
||
public class Is_decorated_with_condtional_CONTRACTS_FULL | ||
public class Is_decorated_with | ||
{ | ||
[Test] | ||
public void Collection_mutation_attribute() | ||
=> typeof(Qowaiv.Diagnostics.Contracts.CollectionMutationAttribute) | ||
.Should().DecoratedWithConditionalAttribute("CONTRACTS_FULL"); | ||
|
||
[Test] | ||
public void Fluent_syntax_attribute() | ||
=> typeof(Qowaiv.Diagnostics.Contracts.FluentSyntaxAttribute) | ||
.Should().DecoratedWithConditionalAttribute("CONTRACTS_FULL"); | ||
|
||
[Test] | ||
public void Impure_attribute() | ||
=> typeof(Qowaiv.Diagnostics.Contracts.ImpureAttribute) | ||
.Should().DecoratedWithConditionalAttribute("CONTRACTS_FULL"); | ||
|
||
[Test] | ||
public void Inheritable_attribute() | ||
=> typeof(Qowaiv.Diagnostics.Contracts.InheritableAttribute) | ||
.Should().DecoratedWithConditionalAttribute("CONTRACTS_FULL"); | ||
|
||
[Test] | ||
public void Mutable_attribute() | ||
=> typeof(Qowaiv.Diagnostics.Contracts.MutableAttribute) | ||
.Should().DecoratedWithConditionalAttribute("CONTRACTS_FULL"); | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.CollectionMutationAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.FluentSyntaxAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.ImpureAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.InheritableAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.MutableAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyTypeAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyClassAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyEnumAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyInterfaceAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyStructAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyTestClassAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyTestEnumAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyTestInterfaceAttribute))] | ||
[TestCase(typeof(Qowaiv.Diagnostics.Contracts.EmptyTestStructAttribute))] | ||
public void condtional_CONTRACTS_FULL(Type attribute) | ||
=> attribute.Should().BeDecoratedWith<ConditionalAttribute>() | ||
.Which.ConditionString.Should().Be("CONTRACTS_FULL"); | ||
} |
32 changes: 32 additions & 0 deletions
32
specs/Qowaiv.Specs/Diagnostics/Contracts/Empty_type_attribute_specs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace Diagnostics.Contracts.Empty_type_attribute_specs; | ||
|
||
public class Can_decorate_empty | ||
{ | ||
[Test] | ||
public void Classes() | ||
=> typeof(SomeEmptyClass).Should().BeDecoratedWith<EmptyTestClassAttribute>(); | ||
|
||
[Test] | ||
public void Enums() | ||
=> typeof(SomeEmptyEnumeration).Should().BeDecoratedWith<EmptyTestEnumAttribute>(); | ||
|
||
[Test] | ||
public void Interfaces() | ||
=> typeof(ISomeEmptyInterface).Should().BeDecoratedWith<EmptyTestInterfaceAttribute>(); | ||
|
||
[Test] | ||
public void Structs() | ||
=> typeof(SomeEmptyStruct).Should().BeDecoratedWith<EmptyTestStructAttribute>(); | ||
} | ||
|
||
[EmptyTestClass] | ||
internal class SomeEmptyClass { } | ||
|
||
[EmptyTestEnum] | ||
internal enum SomeEmptyEnumeration { } | ||
|
||
[EmptyTestInterface] | ||
internal interface ISomeEmptyInterface { } | ||
|
||
[EmptyTestStruct] | ||
internal struct SomeEmptyStruct { } |
16 changes: 0 additions & 16 deletions
16
specs/Qowaiv.Specs/FluentAssertions/System.Type.Assertions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace Qowaiv.Diagnostics.Contracts; | ||
|
||
/// <summary>Indicates the type is empty by design.</summary> | ||
[Conditional("CONTRACTS_FULL")] | ||
public abstract class EmptyTypeAttribute(string justification) : Attribute | ||
Check warning on line 5 in src/Qowaiv.Diagnostics.Contracts/EmptyTypeAttribute.cs GitHub Actions / Build
Check warning on line 5 in src/Qowaiv.Diagnostics.Contracts/EmptyTypeAttribute.cs GitHub Actions / Build
|
||
{ | ||
/// <summary>THe justification of this decoration.</summary> | ||
public string Justification { get; } = justification; | ||
} | ||
|
||
/// <summary>Indicates the class is empty by design.</summary> | ||
/// <remarks> | ||
/// Using this attribute prevents S2094 (Classes should not be empty) from | ||
/// showing up. | ||
/// </remarks> | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class EmptyClassAttribute(string justification) : EmptyTypeAttribute(justification) { } | ||
|
||
/// <summary>Indicates the enum is empty by design.</summary> | ||
[AttributeUsage(AttributeTargets.Enum, AllowMultiple = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class EmptyEnumAttribute(string justification) : EmptyTypeAttribute(justification) { } | ||
|
||
/// <summary>Indicates the class is empty by design.</summary> | ||
[AttributeUsage(AttributeTargets.Interface, AllowMultiple = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class EmptyInterfaceAttribute(string justification) : EmptyTypeAttribute(justification) { } | ||
|
||
/// <summary>Indicates the struct is empty by design.</summary> | ||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public class EmptyStructAttribute(string justification) : EmptyTypeAttribute(justification) { } | ||
|
||
/// <summary>Indicates the class is empty by design.</summary> | ||
/// <remarks> | ||
/// Using this attribute prevents S2094 (Classes should not be empty) from | ||
/// showing up. | ||
/// </remarks> | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class EmptyTestClassAttribute(string? justification = null) : EmptyClassAttribute(justification ?? "For test purposes.") { } | ||
|
||
/// <summary>Indicates the enum is empty by design.</summary> | ||
[AttributeUsage(AttributeTargets.Enum, AllowMultiple = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class EmptyTestEnumAttribute(string? justification = null) : EmptyEnumAttribute(justification ?? "For test purposes.") { } | ||
|
||
/// <summary>Indicates the class is empty by design.</summary> | ||
[AttributeUsage(AttributeTargets.Interface, AllowMultiple = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class EmptyTestInterfaceAttribute(string? justification = null) : EmptyInterfaceAttribute(justification ?? "For test purposes.") { } | ||
|
||
/// <summary>Indicates the struct is empty by design.</summary> | ||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)] | ||
[Conditional("CONTRACTS_FULL")] | ||
public sealed class EmptyTestStructAttribute(string? justification = null) : EmptyStructAttribute(justification ?? "For test purposes.") { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.