Skip to content

Instantly share code, notes, and snippets.

@daleth90
Last active April 1, 2018 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daleth90/31dff07e14ed350c305d2404e4f623cd to your computer and use it in GitHub Desktop.
Save daleth90/31dff07e14ed350c305d2404e4f623cd to your computer and use it in GitHub Desktop.
using Moq;
using NUnit.Framework;
using Zenject;
[TestFixture]
public class OthelloBoardPresenterTests : ZenjectUnitTestFixture {
[Test]
public void ViewInvokeOnClickTileEventAt3d_Default_ModelTryPlaceDiskAt3d() {
Mock<IOthelloBoardModel> mockModel = new Mock<IOthelloBoardModel>();
Mock<IOthelloBoardView> mockView = new Mock<IOthelloBoardView>();
Container.Bind<IOthelloBoardModel>().FromInstance( mockModel.Object ).AsSingle();
Container.Bind<IOthelloBoardView>().FromInstance( mockView.Object ).AsSingle();
Container.Bind<OthelloBoardPresenter>().AsSingle();
Container.Resolve<OthelloBoardPresenter>();
mockView.Raise( view => view.OnClickTile += null, 3, 4 );
mockModel.Verify( model => model.TryPlaceDisk( 3, 4 ) );
}
[Test]
public void ModelInvokeOnPlaceDiskEventAt3d_Default_ViewPlaceDiskAt3d() {
Mock<IOthelloBoardModel> mockModel = new Mock<IOthelloBoardModel>();
Mock<IOthelloBoardView> mockView = new Mock<IOthelloBoardView>();
Container.Bind<IOthelloBoardModel>().FromInstance( mockModel.Object ).AsSingle();
Container.Bind<IOthelloBoardView>().FromInstance( mockView.Object ).AsSingle();
Container.Bind<OthelloBoardPresenter>().AsSingle();
Container.Resolve<OthelloBoardPresenter>();
mockModel.Raise( model => model.OnPlaceDisk += null, 3, 4, It.IsAny<Disk>() );
mockView.Verify( view => view.PlaceDisk( 3, 4, It.IsAny<Disk>() ) );
}
[Test]
public void ModelInvokeOnFlipDiskEventAt4d_Default_ViewFlipDiskAt4d() {
Mock<IOthelloBoardModel> mockModel = new Mock<IOthelloBoardModel>();
Mock<IOthelloBoardView> mockView = new Mock<IOthelloBoardView>();
Container.Bind<IOthelloBoardModel>().FromInstance( mockModel.Object ).AsSingle();
Container.Bind<IOthelloBoardView>().FromInstance( mockView.Object ).AsSingle();
Container.Bind<OthelloBoardPresenter>().AsSingle();
Container.Resolve<OthelloBoardPresenter>();
mockModel.Raise( model => model.OnFlipDisk += null, 4, 4 );
mockView.Verify( view => view.FlipDisk( 4, 4 ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment