-
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.
* Implement generic ItemProperty test. * Implement ItemProperty tests. * Seal classes. * Add event test. * Add basic tests for other engine types. * Fix ItemProperty.OnMonsterHitProperties method. * Cleanup. * Correct test parameters. * Set cost table value to -1.
- Loading branch information
1 parent
6be0db7
commit beddf0c
Showing
7 changed files
with
794 additions
and
1 deletion.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
NWN.Anvil.Tests/src/main/API/EngineStructures/EventTests.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,19 @@ | ||
using NUnit.Framework; | ||
using NWN.Core; | ||
using Event = Anvil.API.Event; | ||
|
||
namespace Anvil.Tests.API | ||
{ | ||
[TestFixture(Category = "API.EngineStructure")] | ||
public sealed class EventTests | ||
{ | ||
[Test(Description = "Creating an event and disposing the event explicitly frees the associated memory.")] | ||
public void CreateAndDisposeEventFreesNativeStructure() | ||
{ | ||
Event nwEvent = NWScript.EventUserDefined(0xDEAD)!; | ||
Assert.That(nwEvent.IsValid, Is.True, "Event was not valid after creation."); | ||
nwEvent.Dispose(); | ||
Assert.That(nwEvent.IsValid, Is.False, "Event was still valid after disposing."); | ||
} | ||
} | ||
} |
697 changes: 697 additions & 0 deletions
697
NWN.Anvil.Tests/src/main/API/EngineStructures/ItemPropertyTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
NWN.Anvil.Tests/src/main/API/EngineStructures/JsonTests.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,20 @@ | ||
using Anvil.API; | ||
using NUnit.Framework; | ||
|
||
namespace Anvil.Tests.API | ||
{ | ||
[TestFixture(Category = "API.EngineStructure")] | ||
public sealed class JsonTests | ||
{ | ||
[Test(Description = "Creating a json structure and disposing it explicitly frees the associated memory.")] | ||
public void CreateAndDisposeJsonFreesNativeStructure() | ||
{ | ||
int[] test = { 1, 2 }; | ||
Json json = JsonUtility.ToJsonStructure(test); | ||
|
||
Assert.That(json.IsValid, Is.True, "Json struct was not valid after creation."); | ||
json.Dispose(); | ||
Assert.That(json.IsValid, Is.False, "Json struct was still valid after disposing."); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
NWN.Anvil.Tests/src/main/API/EngineStructures/LocationTests.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,18 @@ | ||
using Anvil.API; | ||
using NUnit.Framework; | ||
|
||
namespace Anvil.Tests.API | ||
{ | ||
[TestFixture(Category = "API.EngineStructure")] | ||
public class LocationTests | ||
{ | ||
[Test(Description = "Creating a location and disposing the location explicitly frees the associated memory.")] | ||
public void CreateAndDisposeLocationFreesNativeStructure() | ||
{ | ||
Location location = NwModule.Instance.StartingLocation; | ||
Assert.That(location.IsValid, Is.True, "Location was not valid after creation."); | ||
location.Dispose(); | ||
Assert.That(location.IsValid, Is.False, "Location was still valid after disposing."); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
NWN.Anvil.Tests/src/main/API/EngineStructures/SQLQueryTests.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,18 @@ | ||
using Anvil.API; | ||
using NUnit.Framework; | ||
|
||
namespace Anvil.Tests.API | ||
{ | ||
[TestFixture(Category = "API.EngineStructure")] | ||
public class SQLQueryTests | ||
{ | ||
[Test(Description = "Creating a SQL query and disposing the query explicitly frees the associated memory.")] | ||
public void CreateAndDisposeSQLQueryFreesNativeStructure() | ||
{ | ||
SQLQuery query = NwModule.Instance.PrepareSQLQuery("SELECT * FROM 'test'"); | ||
Assert.That(query.IsValid, Is.True, "SQL query was not valid after creation."); | ||
query.Dispose(); | ||
Assert.That(query.IsValid, Is.False, "SQL query was still valid after disposing."); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
NWN.Anvil.Tests/src/main/API/EngineStructures/TalentTests.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,18 @@ | ||
using Anvil.API; | ||
using NUnit.Framework; | ||
|
||
namespace Anvil.Tests.API | ||
{ | ||
[TestFixture(Category = "API.EngineStructure")] | ||
public class TalentTests | ||
{ | ||
[Test(Description = "Creating a talent and disposing the talent explicitly frees the associated memory.")] | ||
public void CreateAndDisposeTalentFreesNativeStructure() | ||
{ | ||
Talent talent = NwSkill.FromSkillType(Skill.Intimidate)!.ToTalent(); | ||
Assert.That(talent.IsValid, Is.True, "Talent was not valid after creation."); | ||
talent.Dispose(); | ||
Assert.That(talent.IsValid, Is.False, "Talent was still valid after disposing."); | ||
} | ||
} | ||
} |
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