CascadesCarnivoreProject / Carnassial

Carnassial: Simplifying Remote Camera Data
Other
3 stars 0 forks source link

Unit test in Timelapse fails due to Constants.Images constructor not being invoked #90

Closed saulgreenberg closed 8 years ago

saulgreenberg commented 8 years ago

The static class Images (in Constants.cs) includes a static constructor that sets the various Images.Corrupt, Images.Missing etc

When Timelapse is used normally, this constructor is invoked so all is well. However, when Timelapse is used within the unit test, the constructor is NOT invoked, and any references to Images.Corrupt etc. leads to failure.

This is a really odd bug - it doesn't seem to be in the code. The C# documentation states that the constructor will be invoked whenever one of the class variables are referenced, which seems to happen fine in normal use but not during unit testing. Weird.

saulgreenberg commented 8 years ago

My notes:

When testing Timelapse unit test, need to remove the .ddb and .tdb files in the UnitTests/bin/Debug/UserInterfaceTests folder as otherwise it uses that .ddb rather than loading the images from scratch.

Issue 1. Fixed one part of this in Constants.Images constructor, where Application.ResourceAssembly is now set if its null.

Issue 2. Nasty. Narrowed it to bitmap manipulations when loading images from the folder, but with varying inconsistent results (arising from threading?) To test, put a break point here, which seems to isolate the issues somewhat: In TimelapseWIndow.xaml.cs bitmapSource = imageProperties.LoadBitmap(this.FolderPath);

and imageProperties.ImageQuality = bitmapSource.AsWriteable().GetImageQuality(this.state.DarkPixelThreshold, this.state.DarkPixelRatioThreshold);

Could this be somehow be related to differences between using OnLoad vs None for BitmapCache? Need to check.

saulgreenberg commented 8 years ago

There are also a few other unit failures to return to. Most are inconsequential, i.e., as a result of changing a few default literals in the program, where the original literals are hard-wired into the unit test and thus don't pass comparison tests.