bradhannah / Ultima5Redux

A mostly true to the original Ultima 5 remake in C# using the original U5 data files.
https://u5redux.wordpress.com/
MIT License
65 stars 7 forks source link

Adding saves to unit tests #447

Closed mandlar closed 1 year ago

mandlar commented 1 year ago

Hello @bradhannah!

I was able to get unit tests working, but had to make a few modifications.

The directory paths could probably be simplified more but wasn't quite sure about non-Windows environments since you have a check for OSX. And as well I'm not sure where TestContext.Parameters() gets data from.

For example, this directory variable:

private string SaveRootDirectory =>
            TestContext.Parameters.Get("SaveRootDirectory",
                RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
                    ? @"/Users/bradhannah/GitHub/Ultima5ReduxTestDependancies/Saves"
                    //@"/Users/bradhannah/games/u5tests"
                    : GetDirectory(DirectoryType.LegacySaves));

Could be reduced to something like:

private string SaveRootDirectory =>
            GetDirectory(DirectoryType.LegacySaves);

But I didn't want to break anything for you :)

All of the tests pass for me (except for the ones with the missing save files).

Thanks! Bryan

bradhannah commented 1 year ago

Hey @mandlar (Bryan)! Apologies for > 1 month delay. I reviewed the changes and like what you did. I even removed my own hardcoded path and used your function. Glad you got them to run. Never had someone actually try to run my unit tests lol!

The .gitignore was a nice touch for the "just in case" scenario too.

I am adding in the missing tests as well. The "new saves" have morphed many times and need constant updating as I change the alter the save schema.

Thanks again! - Brad

mandlar commented 1 year ago

No problem, glad you liked the changes! I just figured I'd start somewhere easy and getting unit tests to work seemed like a good candidate!