public void CreateUser_Action_Fails()
        {
            // Arrange
            var userDto = TestHelper.UserDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.UserService.CreateUser(userDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new CreateUser <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(userDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
Exemplo n.º 2
0
        private void InitButtonCreate()
        {
            buttonCreate.Enabled = false;

            buttonCreate.Click += (_, e) =>
            {
                // pass data to presenter
                Password        = textBoxPassword.Text;
                ReEnterPassword = textBoxReEnterPassword.Text;
                ID        = textBoxID.Text;
                AddedUser = GetUserFromUI();

                CreateUser?.Invoke(this, e);

                MessageBox.Show(ResponseMessage);
            };
        }