-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
568 additions
and
187 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace Libiada.Core.Tests.Attributes; | ||
|
||
using Libiada.Core.Attributes; | ||
using Libiada.Core.Extensions; | ||
using Libiada.Core.Core; | ||
|
||
/// <summary> | ||
/// The binding attribute tests. | ||
/// </summary> | ||
[TestFixture(TestOf = typeof(BindingAttribute))] | ||
public class BindingAttributeTests | ||
{ | ||
/// <summary> | ||
/// Invalid binding value test. | ||
/// </summary> | ||
[Test] | ||
public void InvalidBindingValueTest() | ||
{ | ||
Assert.Throws<ArgumentException>(() => new BindingAttribute((Binding)3)); | ||
} | ||
|
||
/// <summary> | ||
/// Binding attribute value test. | ||
/// </summary> | ||
/// <param name="value"> | ||
/// The value. | ||
/// </param> | ||
[Test] | ||
public void BindingAttributeValueTest([Values] Binding value) | ||
{ | ||
BindingAttribute attribute = new(value); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(attribute.Value, Is.EqualTo(value)); | ||
Assert.That(attribute.Value.GetDisplayValue(), Is.EqualTo(value.GetDisplayValue())); | ||
}); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Libiada.Core.Tests/Attributes/BindingModeAttributeTests.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,38 @@ | ||
namespace Libiada.Core.Tests.Attributes; | ||
|
||
using Libiada.Core.Attributes; | ||
using Libiada.Core.Extensions; | ||
using Libiada.Core.Core; | ||
|
||
/// <summary> | ||
/// The binding mode attribute tests. | ||
/// </summary> | ||
[TestFixture(TestOf = typeof(BindingModeAttribute))] | ||
public class BindingModeAttributeTests | ||
{ | ||
/// <summary> | ||
/// Invalid binding mode value test. | ||
/// </summary> | ||
[Test] | ||
public void InvalidBindingModeValueTest() | ||
{ | ||
Assert.Throws<ArgumentException>(() => new BindingModeAttribute((BindingMode)5)); | ||
} | ||
|
||
/// <summary> | ||
/// Binding mode attribute value test. | ||
/// </summary> | ||
/// <param name="value"> | ||
/// The value. | ||
/// </param> | ||
[Test] | ||
public void BindingModeAttributeValueTest([Values] BindingMode value) | ||
{ | ||
BindingModeAttribute attribute = new(value); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(attribute.Value, Is.EqualTo(value)); | ||
Assert.That(attribute.Value.GetDisplayValue(), Is.EqualTo(value.GetDisplayValue())); | ||
}); | ||
} | ||
} |
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,38 @@ | ||
namespace Libiada.Core.Tests.Attributes; | ||
|
||
using Libiada.Core.Attributes; | ||
using Libiada.Core.Extensions; | ||
using Libiada.Core.Core; | ||
|
||
/// <summary> | ||
/// The link attribute tests. | ||
/// </summary> | ||
[TestFixture(TestOf = typeof(LinkAttribute))] | ||
public class LinkAttributeTests | ||
{ | ||
/// <summary> | ||
/// Invalid link value test. | ||
/// </summary> | ||
[Test] | ||
public void InvalidLinkValueTest() | ||
{ | ||
Assert.Throws<ArgumentException>(() => new LinkAttribute((Link)8)); | ||
} | ||
|
||
/// <summary> | ||
/// Link attribute value test. | ||
/// </summary> | ||
/// <param name="value"> | ||
/// The value. | ||
/// </param> | ||
[Test] | ||
public void LinkAttributeValueTest([Values] Link value) | ||
{ | ||
LinkAttribute attribute = new(value); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(attribute.Value, Is.EqualTo(value)); | ||
Assert.That(attribute.Value.GetDisplayValue(), Is.EqualTo(value.GetDisplayValue())); | ||
}); | ||
} | ||
} |
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,79 @@ | ||
namespace Libiada.Core.Tests.Core; | ||
|
||
using Libiada.Core.Core; | ||
using Libiada.Core.Extensions; | ||
|
||
/// <summary> | ||
/// BindingMode enum tests. | ||
/// </summary> | ||
[TestFixture(TestOf = typeof(BindingMode))] | ||
public class BindingModeTests | ||
{ | ||
/// <summary> | ||
/// Binding modes count. | ||
/// </summary> | ||
private const int BindingModesCount = 5; | ||
|
||
/// <summary> | ||
/// Array of all binding modes. | ||
/// </summary> | ||
private readonly BindingMode[] bindingModes = EnumExtensions.ToArray<BindingMode>(); | ||
|
||
/// <summary> | ||
/// Tests count of binding modes. | ||
/// </summary> | ||
[Test] | ||
public void BindingModeCountTest() => Assert.That(bindingModes, Has.Length.EqualTo(BindingModesCount)); | ||
|
||
/// <summary> | ||
/// Tests values of binding modes. | ||
/// </summary> | ||
[Test] | ||
public void BindingModeValuesTest() | ||
{ | ||
for (int i = 0; i < BindingModesCount; i++) | ||
{ | ||
Assert.That(bindingModes, Contains.Item((BindingMode)i)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Tests names of binding modes. | ||
/// </summary> | ||
/// <param name="bindingMode"> | ||
/// The binding mode. | ||
/// </param> | ||
/// <param name="name"> | ||
/// The name. | ||
/// </param> | ||
[TestCase((BindingMode)0, "NotApplicable")] | ||
[TestCase((BindingMode)1, "Normal")] | ||
[TestCase((BindingMode)2, "Cyclic")] | ||
[TestCase((BindingMode)3, "Lossy")] | ||
[TestCase((BindingMode)4, "Redundant")] | ||
public void BindingModeNamesTest(BindingMode bindingMode, string name) => Assert.That(bindingMode.GetName(), Is.EqualTo(name)); | ||
|
||
/// <summary> | ||
/// Tests that all binding modes have display value. | ||
/// </summary> | ||
/// <param name="bindingMode"> | ||
/// The binding mode. | ||
/// </param> | ||
[Test] | ||
public void BindingModeHasDisplayValueTest([Values] BindingMode bindingMode) => Assert.That(bindingMode.GetDisplayValue(), Is.Not.Empty); | ||
|
||
/// <summary> | ||
/// Tests that all binding modes have description. | ||
/// </summary> | ||
/// <param name="bindingMode"> | ||
/// The binding mode. | ||
/// </param> | ||
[Test] | ||
public void BindingModeHasDescriptionTest([Values] BindingMode bindingMode) => Assert.That(bindingMode.GetDescription(), Is.Not.Empty); | ||
|
||
/// <summary> | ||
/// Tests that all binding modes values are unique. | ||
/// </summary> | ||
[Test] | ||
public void BindingModeValuesUniqueTest() => Assert.That(bindingModes.Cast<byte>(), Is.Unique); | ||
} |
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,77 @@ | ||
namespace Libiada.Core.Tests.Core; | ||
|
||
using Libiada.Core.Core; | ||
using Libiada.Core.Extensions; | ||
|
||
/// <summary> | ||
/// Binding enum tests. | ||
/// </summary> | ||
[TestFixture(TestOf = typeof(Binding))] | ||
public class BindingTests | ||
{ | ||
/// <summary> | ||
/// Bindings count. | ||
/// </summary> | ||
private const int BindingsCount = 3; | ||
|
||
/// <summary> | ||
/// Array of all bindings. | ||
/// </summary> | ||
private readonly Binding[] bindings = EnumExtensions.ToArray<Binding>(); | ||
|
||
/// <summary> | ||
/// Tests count of bindings. | ||
/// </summary> | ||
[Test] | ||
public void BindingCountTest() => Assert.That(bindings, Has.Length.EqualTo(BindingsCount)); | ||
|
||
/// <summary> | ||
/// Tests values of bindings. | ||
/// </summary> | ||
[Test] | ||
public void BindingValuesTest() | ||
{ | ||
for (int i = 0; i < BindingsCount; i++) | ||
{ | ||
Assert.That(bindings, Contains.Item((Binding)i)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Tests names of bindings. | ||
/// </summary> | ||
/// <param name="binding"> | ||
/// The binding. | ||
/// </param> | ||
/// <param name="name"> | ||
/// The name. | ||
/// </param> | ||
[TestCase((Binding)0, "NotApplicable")] | ||
[TestCase((Binding)1, "Beginning")] | ||
[TestCase((Binding)2, "End")] | ||
public void BindingNamesTest(Binding binding, string name) => Assert.That(binding.GetName(), Is.EqualTo(name)); | ||
|
||
/// <summary> | ||
/// Tests that all bindings have display value. | ||
/// </summary> | ||
/// <param name="binding"> | ||
/// The binding. | ||
/// </param> | ||
[Test] | ||
public void BindingHasDisplayValueTest([Values] Binding binding) => Assert.That(binding.GetDisplayValue(), Is.Not.Empty); | ||
|
||
/// <summary> | ||
/// Tests that all bindings have description. | ||
/// </summary> | ||
/// <param name="binding"> | ||
/// The binding. | ||
/// </param> | ||
[Test] | ||
public void BindingHasDescriptionTest([Values] Binding binding) => Assert.That(binding.GetDescription(), Is.Not.Empty); | ||
|
||
/// <summary> | ||
/// Tests that all bindings values are unique. | ||
/// </summary> | ||
[Test] | ||
public void BindingValuesUniqueTest() => Assert.That(bindings.Cast<byte>(), Is.Unique); | ||
} |
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
Oops, something went wrong.