Skip to content

Commit e453d33

Browse files
committed
test refactoring
1 parent 6ee7836 commit e453d33

7 files changed

Lines changed: 79 additions & 62 deletions

File tree

OVRSharp.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AC203731
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OVRSharp.Graphics.DirectX", "OVRSharp.Graphics.DirectX\OVRSharp.Graphics.DirectX.csproj", "{AF840E83-0D65-4558-8086-F19491B4532B}"
1717
EndProject
18-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OVRSharp.Graphics.DirectX.Tests", "tests\OVRSharp.Graphics.DirectX.Tests\OVRSharp.Graphics.DirectX.Tests.csproj", "{80860435-8D24-48BB-BA3A-25ECB6AA6E0A}"
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OVRSharp.Graphics.DirectX.Tests", "tests\OVRSharp.Graphics.DirectX.Tests\OVRSharp.Graphics.DirectX.Tests.csproj", "{80860435-8D24-48BB-BA3A-25ECB6AA6E0A}"
19+
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OVRSharp.Tests", "tests\OVRSharp.Tests\OVRSharp.Tests.csproj", "{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}"
1921
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -43,6 +45,10 @@ Global
4345
{80860435-8D24-48BB-BA3A-25ECB6AA6E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
4446
{80860435-8D24-48BB-BA3A-25ECB6AA6E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
4547
{80860435-8D24-48BB-BA3A-25ECB6AA6E0A}.Release|Any CPU.Build.0 = Release|Any CPU
48+
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49+
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}.Debug|Any CPU.Build.0 = Debug|Any CPU
50+
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}.Release|Any CPU.ActiveCfg = Release|Any CPU
51+
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}.Release|Any CPU.Build.0 = Release|Any CPU
4652
EndGlobalSection
4753
GlobalSection(SolutionProperties) = preSolution
4854
HideSolutionNode = FALSE
@@ -53,6 +59,7 @@ Global
5359
{C78CB0B3-9DCF-4083-A234-C5FB2661A9B3} = {AC203731-548C-4C7D-95BD-AAA6D7D288FC}
5460
{AF840E83-0D65-4558-8086-F19491B4532B} = {EDA24C40-CE58-429D-A903-19BDE6D024E6}
5561
{80860435-8D24-48BB-BA3A-25ECB6AA6E0A} = {AC203731-548C-4C7D-95BD-AAA6D7D288FC}
62+
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73} = {AC203731-548C-4C7D-95BD-AAA6D7D288FC}
5663
EndGlobalSection
5764
GlobalSection(ExtensibilityGlobals) = postSolution
5865
SolutionGuid = {93984CAB-8CA9-430A-8166-5E2B339CA8A8}
Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,6 @@
1-
using FluentAssertions;
2-
using NUnit.Framework;
3-
using Valve.VR;
1+
using OVRSharp.Tests.Graphics;
42

53
namespace OVRSharp.Graphics.DirectX.Tests
64
{
7-
public class CompositorTests
8-
{
9-
private Application app;
10-
private ICompositorAPI compositor;
11-
12-
[OneTimeSetUp]
13-
public void Setup()
14-
{
15-
app = new Application(Application.ApplicationType.Background);
16-
compositor = new DirectXCompositor();
17-
}
18-
19-
[Test]
20-
[TestCase(EVREye.Eye_Left)]
21-
[TestCase(EVREye.Eye_Right)]
22-
public void ShouldGetMirrorTextureSuccessfully(EVREye eye)
23-
{
24-
var bitmap = compositor.GetMirrorImage(eye);
25-
bitmap.Height.Should().BeGreaterThan(0);
26-
bitmap.Width.Should().BeGreaterThan(0);
27-
}
28-
29-
// This test is mostly here to make sure we are deallocating resources properly.
30-
[Test]
31-
public void ShouldWithstandRapidCalls()
32-
{
33-
for (var i = 0; i < 1000; i++)
34-
{
35-
var bitmap = compositor.GetMirrorImage(EVREye.Eye_Left);
36-
bitmap.Height.Should().BeGreaterThan(0);
37-
bitmap.Width.Should().BeGreaterThan(0);
38-
39-
bitmap.Dispose();
40-
}
41-
}
42-
}
5+
public class DirectXCompositorTests : CompositorTests<DirectXCompositor> { }
436
}

tests/OVRSharp.Graphics.DirectX.Tests/OVRSharp.Graphics.DirectX.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<ItemGroup>
1717
<ProjectReference Include="..\..\OVRSharp.Graphics.DirectX\OVRSharp.Graphics.DirectX.csproj" />
1818
<ProjectReference Include="..\..\OVRSharp\OVRSharp.csproj" />
19+
<ProjectReference Include="..\OVRSharp.Tests\OVRSharp.Tests.csproj" />
1920
</ItemGroup>
2021

2122
</Project>
Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
using FluentAssertions;
22
using NUnit.Framework;
3+
using OVRSharp.Tests.Graphics;
34
using Valve.VR;
45

56
namespace OVRSharp.Graphics.OpenGL.Tests
67
{
7-
public class CompositorTests
8-
{
9-
private Application app;
10-
private ICompositorAPI compositor;
11-
12-
[OneTimeSetUp]
13-
public void Setup()
14-
{
15-
app = new Application(Application.ApplicationType.Background);
16-
compositor = new OpenGLCompositor();
17-
}
18-
19-
[Test]
20-
[TestCase(EVREye.Eye_Left)]
21-
[TestCase(EVREye.Eye_Right)]
22-
public void ShouldGetMirrorTextureSuccessfully(EVREye eye)
23-
{
24-
var bitmap = compositor.GetMirrorImage(eye);
25-
bitmap.Height.Should().BeGreaterThan(0);
26-
bitmap.Width.Should().BeGreaterThan(0);
27-
}
28-
}
8+
public class OpenGLCompositorTests : CompositorTests<OpenGLCompositor> { }
299
}

tests/OVRSharp.Graphics.OpenGL.Tests/OVRSharp.Graphics.OpenGL.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<ItemGroup>
1717
<ProjectReference Include="..\..\OVRSharp.Graphics.OpenGL\OVRSharp.Graphics.OpenGL.csproj" />
1818
<ProjectReference Include="..\..\OVRSharp\OVRSharp.csproj" />
19+
<ProjectReference Include="..\OVRSharp.Tests\OVRSharp.Tests.csproj" />
1920
</ItemGroup>
2021

2122
</Project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using FluentAssertions;
2+
using NUnit.Framework;
3+
using OVRSharp.Graphics;
4+
using Valve.VR;
5+
6+
namespace OVRSharp.Tests.Graphics
7+
{
8+
public class CompositorTests<T> where T : ICompositorAPI, new()
9+
{
10+
private Application app;
11+
private ICompositorAPI compositor;
12+
13+
[OneTimeSetUp]
14+
public void Setup()
15+
{
16+
app = new Application(Application.ApplicationType.Background);
17+
compositor = new T();
18+
}
19+
20+
[Test]
21+
[TestCase(EVREye.Eye_Left)]
22+
[TestCase(EVREye.Eye_Right)]
23+
public void ShouldGetMirrorTextureSuccessfully(EVREye eye)
24+
{
25+
var bitmap = compositor.GetMirrorImage(eye);
26+
bitmap.Height.Should().BeGreaterThan(0);
27+
bitmap.Width.Should().BeGreaterThan(0);
28+
}
29+
30+
// This test is mostly here to make sure we are deallocating resources properly.
31+
[Test]
32+
public void ShouldWithstandRapidCalls()
33+
{
34+
Assert.Ignore();
35+
for (var i = 0; i < 1000; i++)
36+
{
37+
var bitmap = compositor.GetMirrorImage(EVREye.Eye_Left);
38+
bitmap.Height.Should().BeGreaterThan(0);
39+
bitmap.Width.Should().BeGreaterThan(0);
40+
41+
bitmap.Dispose();
42+
}
43+
}
44+
}
45+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="FluentAssertions" Version="5.10.3" />
11+
<PackageReference Include="NUnit" Version="3.12.0" />
12+
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\..\OVRSharp\OVRSharp.csproj" />
18+
</ItemGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)