public async Task ConnectionStatusChangedRaisedWhenClosing() { await this.StartMockServerAndConnectClientAsync(); connectionChangedSubscriber.Reset(); await this.wsClient.CloseAsync(); Assert.AreEqual(1, connectionChangedSubscriber.HitCount); Assert.AreEqual(new[] { ConnectionStates.Disconnected }, connectionChangedSubscriber.ReceivedEventArgs); }
public void ChangeSelection_Position_SelectionChangedRaised( int pointCount, int newPointModelIndex, int stubPointModelIndex, int expectedCallCount) { // Arrange var stubPoints = TestHelper.CreatePointsWithBounds(pointCount); var stubBoardService = Substitute.For <IBoardService>(); stubBoardService.CreateInitialBoard() .Returns(new Tuple <List <PointModel>, List <List <PointModel> > >(stubPoints, null)); var stubBoardModel = Substitute.For <BoardModel>(stubBoardService); var mockEventSubscriber = new MockEventSubscriber(); stubBoardModel.NewPieceAdded += mockEventSubscriber.Handle; stubBoardModel.SelectionChanged += mockEventSubscriber.Handle; var stubPlayer = Substitute.For <PlayerModel>(1, Colors.Yellow); var boardController = new BoardController(stubBoardModel); boardController.AddNewPiece(stubPoints[stubPointModelIndex], stubPlayer); mockEventSubscriber.Reset(); // Act boardController.ChangeSelection(stubPoints[newPointModelIndex], stubPlayer, true); // Assert Assert.AreEqual(expectedCallCount, mockEventSubscriber.HitCount); }