forked from UnderminersTeam/UndertaleModTool
-
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.
Converted tests to xunit, joined both projects since they both only test the lib anyway. They still fail, but that's to be fixed later. I just wanted start organizing it for now.
- Loading branch information
1 parent
dc1e209
commit 4ab51a3
Showing
13 changed files
with
558 additions
and
620 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,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UndertaleModLib.Models; | ||
|
||
namespace UndertaleModLib.Tests | ||
{ | ||
public class EmbeddedAudioTest | ||
{ | ||
[Theory] | ||
[InlineData(new byte[] | ||
{ | ||
4, 0, 0, 0, | ||
252, 253, 254, 255, | ||
} | ||
)] | ||
public void TestUnserialize(byte[] data) | ||
{ | ||
using var stream = new MemoryStream(data); | ||
var reader = new UndertaleReader(stream); | ||
var embeddedAudio = new UndertaleEmbeddedAudio(); | ||
|
||
embeddedAudio.Unserialize(reader); | ||
|
||
Assert.True(embeddedAudio.Data.Length == BitConverter.ToInt32(data[..4])); | ||
Assert.Equal(embeddedAudio.Data, data[4..]); | ||
} | ||
|
||
[Theory] | ||
[InlineData(new byte[] | ||
{ | ||
4, 0, 0, 0, | ||
252, 253, 254, 255 | ||
} | ||
)] | ||
public void TestSerialize(byte[] data) | ||
{ | ||
using var stream = new MemoryStream(); | ||
UndertaleEmbeddedAudio audio = new UndertaleEmbeddedAudio() | ||
{ | ||
Name = new UndertaleString("foobar"), | ||
Data = data[4..] | ||
}; | ||
var writer = new UndertaleWriter(stream); | ||
|
||
audio.Serialize(writer); | ||
|
||
Assert.True(stream.Length == data.Length); | ||
Assert.Equal(stream.ToArray(), data); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace UndertaleModLib.Tests | ||
{ | ||
static class GamePaths | ||
{ | ||
// TODO: Maybe these should be configuration variables? | ||
//public static string UNDERTALE_PATH = @"C:\Program Files (x86)\Steam\steamapps\common\Undertale\data.win"; | ||
public static string UNDERTALE_PATH = @"D:\SteamLibrary\steamapps\common\Undertale\data.win"; | ||
public static string UNDERTALE_MD5 = "5903fc5cb042a728d4ad8ee9e949c6eb"; | ||
public static string UNDERTALE_SWITCH_PATH = @"..\..\..\Test\bin\Debug\switch\game.win"; | ||
public static string UNDERTALE_SWITCH_MD5 = "427520a97db28c87da4220abb3a334c1"; | ||
public static string DELTARUNE_PATH = @"C:\Program Files (x86)\SURVEY_PROGRAM\data.win"; | ||
public static string DELTARUNE_MD5 = "a88a2db3a68c714ca2b1ff57ac08a032"; | ||
} | ||
} |
Oops, something went wrong.