-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validation of DeviceConfiguration. Tests on this validation. More tes…
…ts on Image class. Minor improvements.
- Loading branch information
Showing
10 changed files
with
403 additions
and
61 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
86 changes: 86 additions & 0 deletions
86
K4AdotNet.Tests.SensorTypesUnitTests/DeviceConfigurationTests.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,86 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using K4AdotNet.Sensor; | ||
|
||
namespace K4AdotNet.Tests.SensorTypesUnitTests | ||
{ | ||
[TestClass] | ||
public class DeviceConfigurationTests | ||
{ | ||
[TestMethod] | ||
public void TestThatDisableAllConfigIsValid() | ||
{ | ||
var config = DeviceConfiguration.DisableAll; | ||
|
||
Assert.IsTrue(config.IsValid(out var message)); | ||
Assert.IsNull(message); | ||
} | ||
|
||
[TestMethod] | ||
public void TestValidConfig() | ||
{ | ||
var config = new DeviceConfiguration | ||
{ | ||
CameraFps = FrameRate.Thirty, | ||
ColorFormat = ImageFormat.ColorMjpg, | ||
ColorResolution = ColorResolution.R720p, | ||
DepthMode = DepthMode.NarrowViewUnbinned, | ||
WiredSyncMode = WiredSyncMode.Standalone, | ||
}; | ||
|
||
Assert.IsTrue(config.IsValid(out var message)); | ||
Assert.IsNull(message); | ||
} | ||
|
||
[TestMethod] | ||
public void TestInvalidConfigs() | ||
{ | ||
var config = new DeviceConfiguration | ||
{ | ||
CameraFps = FrameRate.Thirty, | ||
ColorFormat = ImageFormat.ColorMjpg, | ||
ColorResolution = ColorResolution.R720p, | ||
DepthMode = DepthMode.WideViewUnbinned, // this mode is not compatible with 30 FPS | ||
WiredSyncMode = WiredSyncMode.Standalone, | ||
}; | ||
|
||
Assert.IsFalse(config.IsValid(out var message)); | ||
Assert.IsNotNull(message); | ||
|
||
config = new DeviceConfiguration | ||
{ | ||
CameraFps = FrameRate.Thirty, | ||
ColorFormat = ImageFormat.ColorMjpg, | ||
ColorResolution = ColorResolution.R3072p, // this resolution is not compatible with 30 FPS | ||
DepthMode = DepthMode.Off, | ||
WiredSyncMode = WiredSyncMode.Standalone, | ||
}; | ||
|
||
Assert.IsFalse(config.IsValid(out message)); | ||
Assert.IsNotNull(message); | ||
|
||
config = new DeviceConfiguration | ||
{ | ||
CameraFps = FrameRate.Fifteen, | ||
ColorFormat = ImageFormat.ColorNV12, | ||
ColorResolution = ColorResolution.R1080p, // this resolution is not compatible with NV12 | ||
DepthMode = DepthMode.Off, | ||
WiredSyncMode = WiredSyncMode.Standalone, | ||
}; | ||
|
||
Assert.IsFalse(config.IsValid(out message)); | ||
Assert.IsNotNull(message); | ||
|
||
config = new DeviceConfiguration | ||
{ | ||
CameraFps = FrameRate.Fifteen, | ||
ColorFormat = ImageFormat.IR16, // <- oops! | ||
ColorResolution = ColorResolution.Off, | ||
DepthMode = DepthMode.Off, | ||
WiredSyncMode = WiredSyncMode.Standalone, | ||
}; | ||
|
||
Assert.IsFalse(config.IsValid(out message)); | ||
Assert.IsNotNull(message); | ||
} | ||
} | ||
} |
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.