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
using NUnit.Framework; | |
using Zenject; | |
[TestFixture] | |
public class OthelloBoardModelTests : ZenjectUnitTestFixture { | |
[Test] | |
public void TryPlaceDiskAt3d_Default_InvokeOnPlaceDiskEventAt3d() { | |
OthelloBoardModel model = Container.Instantiate<OthelloBoardModel>(); | |
int actualX = 0, actualY = 0; | |
model.OnPlaceDisk += delegate ( int x, int y, Disk disk ) { | |
actualX = x; | |
actualY = y; | |
}; | |
model.TryPlaceDisk( 3, 4 ); | |
Assert.AreEqual( 3, actualX ); | |
Assert.AreEqual( 4, actualY ); | |
} | |
[Test] | |
public void TryPlaceDiskAt8h_Default_InvokeOnPlaceDiskEventAt8h() { | |
OthelloBoardModel model = Container.Instantiate<OthelloBoardModel>(); | |
int actualX = 0, actualY = 0; | |
model.OnPlaceDisk += delegate ( int x, int y, Disk disk ) { | |
actualX = x; | |
actualY = y; | |
}; | |
model.TryPlaceDisk( 8, 8 ); | |
Assert.AreEqual( 8, actualX ); | |
Assert.AreEqual( 8, actualY ); | |
} | |
[Test] | |
public void TryPlaceDiskOutOfBoard_Default_DoesNotInvokeOnPlaceDiskEvent() { | |
OthelloBoardModel model = Container.Instantiate<OthelloBoardModel>(); | |
bool flag = false; | |
model.OnPlaceDisk += delegate ( int x, int y, Disk disk ) { | |
flag = true; | |
}; | |
model.TryPlaceDisk( 1, 9 ); | |
model.TryPlaceDisk( 0, 8 ); | |
model.TryPlaceDisk( 9, 5 ); | |
model.TryPlaceDisk( 9, -1 ); | |
Assert.AreEqual( false, flag ); | |
} | |
[Test] | |
public void TryPlaceDiskAt3d_DoTwice_TheSecondTimeDoesNotInvokeOnPlaceDiskEvent() { | |
OthelloBoardModel model = Container.Instantiate<OthelloBoardModel>(); | |
model.TryPlaceDisk( 3, 4 ); | |
bool flag = false; | |
model.OnPlaceDisk += delegate ( int x, int y, Disk disk ) { | |
flag = true; | |
}; | |
model.TryPlaceDisk( 3, 4 ); | |
Assert.AreEqual( false, flag ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment