-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
208 changed files
with
1,908 additions
and
445 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
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
50 changes: 50 additions & 0 deletions
50
NWN.Anvil.Tests/src/main/API/EngineStructures/CassowaryTests.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,50 @@ | ||
using Anvil.API; | ||
using NUnit.Framework; | ||
|
||
namespace Anvil.Tests.API | ||
{ | ||
[TestFixture(Category = "API.EngineStructure")] | ||
public sealed class CassowaryTests | ||
{ | ||
[Test(Description = "Creating a new cassowary and disposing the cassowary explicitly frees the associated memory.")] | ||
public void CreateAndDisposeCassowaryValidPropertyUpdated() | ||
{ | ||
Cassowary cassowary = new Cassowary(); | ||
Assert.That(cassowary.IsValid, Is.True, "Cassowary was not valid after creation."); | ||
cassowary.Dispose(); | ||
Assert.That(cassowary.IsValid, Is.False, "Cassowary was still valid after disposing."); | ||
} | ||
|
||
[Test(Description = "A cassowary correctly finds a solution from a set of constraints.")] | ||
public void CreateCassowaryConstraintReturnsValidSolution() | ||
{ | ||
Cassowary cassowary = new Cassowary(); | ||
|
||
cassowary.AddConstraint("middle == (left + right) / 2"); | ||
cassowary.AddConstraint("right == left + 10"); | ||
cassowary.AddConstraint("right <= 100"); | ||
cassowary.AddConstraint("left >= 0"); | ||
|
||
Assert.That(cassowary.GetValue("left"), Is.EqualTo(90f)); | ||
Assert.That(cassowary.GetValue("middle"), Is.EqualTo(95f)); | ||
Assert.That(cassowary.GetValue("right"), Is.EqualTo(100f)); | ||
} | ||
|
||
[Test(Description = "A cassowary correctly finds a solution from a set of constraints and a suggested value.")] | ||
public void CreateCassowaryConstraintWithSuggestedValueReturnsValidSolution() | ||
{ | ||
Cassowary cassowary = new Cassowary(); | ||
|
||
cassowary.AddConstraint("middle == (left + right) / 2"); | ||
cassowary.AddConstraint("right == left + 10"); | ||
cassowary.AddConstraint("right <= 100"); | ||
cassowary.AddConstraint("left >= 0"); | ||
|
||
cassowary.SuggestValue("middle", 45f); | ||
|
||
Assert.That(cassowary.GetValue("left"), Is.EqualTo(40f)); | ||
Assert.That(cassowary.GetValue("middle"), Is.EqualTo(45f)); | ||
Assert.That(cassowary.GetValue("right"), Is.EqualTo(50f)); | ||
} | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
NWN.Anvil.Tests/src/main/API/EngineStructures/ItemPropertyTests.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,34 @@ | ||
using Anvil.API; | ||
using NUnit.Framework; | ||
using NWN.Native.API; | ||
using ItemProperty = Anvil.API.ItemProperty; | ||
|
||
namespace Anvil.Tests.API | ||
{ | ||
[TestFixture(Category = "API.EngineStructure")] | ||
public sealed class ItemPropertyTests | ||
{ | ||
[Test(Description = "Creating an item property and disposing the item property explicitly frees the associated memory.")] | ||
public void CreateAndDisposeItemPropertyFreesNativeStructure() | ||
{ | ||
ItemProperty itemProperty = ItemProperty.Haste(); | ||
Assert.That(itemProperty.IsValid, Is.True, "Item property was not valid after creation."); | ||
itemProperty.Dispose(); | ||
Assert.That(itemProperty.IsValid, Is.False, "Item property was still valid after disposing."); | ||
} | ||
|
||
[Test(Description = "A soft item property reference created from a native object does not cause the original item property to be deleted.")] | ||
public void CreateSoftItemPropertyReferenceAndDisposeDoesNotFreeMemory() | ||
{ | ||
ItemProperty itemProperty = ItemProperty.Haste(); | ||
Assert.That(itemProperty.IsValid, Is.True, "Item property was not valid after creation."); | ||
|
||
CGameEffect gameEffect = itemProperty; | ||
Assert.That(gameEffect, Is.Not.Null, "Native Item property was not valid after implicit cast."); | ||
|
||
ItemProperty softReference = gameEffect.ToItemProperty(false)!; | ||
softReference.Dispose(); | ||
Assert.That(softReference.IsValid, Is.True, "The soft reference disposed the memory of the original item property."); | ||
} | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.