Skip to content

Commit 33cdb67

Browse files
committed
Adds mouse-test structure
1 parent 0c24be7 commit 33cdb67

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

NUnitTests/MouseTests.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// ***************************************************************************
2+
// This is free and unencumbered software released into the public domain.
3+
//
4+
// Anyone is free to copy, modify, publish, use, compile, sell, or
5+
// distribute this software, either in source code form or as a compiled
6+
// binary, for any purpose, commercial or non-commercial, and by any
7+
// means.
8+
//
9+
// In jurisdictions that recognize copyright laws, the author or authors
10+
// of this software dedicate any and all copyright interest in the
11+
// software to the public domain. We make this dedication for the benefit
12+
// of the public at large and to the detriment of our heirs and
13+
// successors. We intend this dedication to be an overt act of
14+
// relinquishment in perpetuity of all present and future rights to this
15+
// software under copyright law.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21+
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
24+
//
25+
// For more information, please refer to <http://unlicense.org>
26+
// ***************************************************************************
27+
28+
using InputStateManager;
29+
using InputStateManager.Inputs.InputProviders.Interfaces;
30+
using Microsoft.Xna.Framework;
31+
using Microsoft.Xna.Framework.Input;
32+
using Moq;
33+
using NUnit.Framework;
34+
35+
namespace NUnitTests
36+
{
37+
[TestFixture]
38+
[Category("InputStateManager.Mouse")]
39+
public class MouseTests
40+
{
41+
private InputManager input;
42+
private Mock<IMouseInputProvider> providerMock;
43+
44+
[SetUp]
45+
public void Setup()
46+
{
47+
providerMock = new Mock<IMouseInputProvider>();
48+
input = new InputManager(null, providerMock.Object, null, null);
49+
}
50+
51+
private static MouseState IdleState => new MouseState(0, 0, 0, ButtonState.Released, ButtonState.Released,
52+
ButtonState.Released, ButtonState.Released, ButtonState.Released);
53+
54+
[Test]
55+
public void KeyDownTriggers()
56+
{
57+
providerMock.SetupSequence(o => o.GetState())
58+
.Returns(IdleState);
59+
input.Update();
60+
Assert.AreEqual(Point.Zero, input.Mouse.Is.Position);
61+
}
62+
}
63+
}

NUnitTests/NUnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<Reference Include="System.Xml" />
6161
</ItemGroup>
6262
<ItemGroup>
63+
<Compile Include="MouseTests.cs" />
6364
<Compile Include="PadTests.cs" />
6465
<Compile Include="KeyTests.cs" />
6566
<Compile Include="Properties\AssemblyInfo.cs" />

0 commit comments

Comments
 (0)