示例#1
0
        public void CanCommit()
        {
            // Arrange
            ClientCreationState clientCreationState = this.GetDefaultState();

            // Assert
            clientCreationState.CanCommit().Should().BeTrue();
        }
 private void InitStates()
 {
     this._clientEmptyState    = new ClientEmptyState(this);
     this._clientSearchState   = new ClientSearchState(this);
     this._clientCreationState = new ClientCreationState(this);
     this._clientLoadedState   = new ClientLoadedState(this);
     this._clientEditState     = new ClientEditState(this);
 }
示例#3
0
        public void CanNotDelete()
        {
            // Arrange
            ClientCreationState clientCreationState = this.GetDefaultState();

            // Assert
            clientCreationState.CanDelete().Should().BeFalse();
        }
示例#4
0
        public void CanNotSwitchToOtherModes()
        {
            // Arrange
            ClientCreationState clientCreationState = this.GetDefaultState();

            // Assert
            clientCreationState.CanSwitchToSearchMode().Should().BeFalse();
            clientCreationState.CanSwitchToAddMode().Should().BeFalse();
            clientCreationState.CanSwitchToEditMode().Should().BeFalse();
        }
示例#5
0
        public void ReturnToPreviousClientAndClientState()
        {
            // Arrange
            Mock <ClientEditViewModel> mockClientEditViewModel = this.GetMockedViewModel();
            ClientCreationState        clientCreationState     = this.GetDefaultState(mockClientEditViewModel);

            // Act
            clientCreationState.Cancel();

            // Assert
            mockClientEditViewModel.Verify(x => x.ChangeToEmptyMode(), Times.Once);
        }
示例#6
0
        public async Task DoNotChangeToClientLoadedStateWhenClientWasNotAddedSuccessfully()
        {
            // Arrange
            Mock <ClientEditViewModel> mockClientEditViewModel = this.GetMockedViewModel();

            mockClientEditViewModel.Setup(x => x.SaveOrUpdateClientAsync()).Returns(Task.FromResult(false));

            ClientCreationState clientCreationState = this.GetDefaultState(mockClientEditViewModel);

            // Act
            await clientCreationState.Commit();

            // Assert
            mockClientEditViewModel.Verify(x => x.ChangeToLoadedMode(null), Times.Never);
        }
示例#7
0
        public async Task SendReloadClientSearchMessageWhenClientWasAddedSuccessfully()
        {
            // Arrange
            Mock <ClientEditViewModel> mockClientEditViewModel = this.GetMockedViewModel();

            mockClientEditViewModel.Setup(x => x.SaveOrUpdateClientAsync()).Returns(Task.FromResult(true));

            NotificationMessage notificationMessage = null;

            Messenger.Default.Register <NotificationMessage>(this, x => notificationMessage = x);

            ClientCreationState clientCreationState = this.GetDefaultState(mockClientEditViewModel);

            // Act
            await clientCreationState.Commit();

            // Assert
            notificationMessage.Should().NotBeNull();
            notificationMessage.Notification.Should().Be(Resources.Message_ReloadClientsForClientSearchVM);
        }