예제 #1
0
        public void DeactivateAdminUser_does_not_deactivate_admin_user_without_confirmation()
        {
            // Given
            var          adminUserId          = UserTestHelper.GetDefaultAdminUser().Id;
            const string expectedErrorMessage = "You must confirm before deactivating this account";

            var deactivateViewModel =
                Builder <DeactivateAdminViewModel> .CreateNew().With(vm => vm.Confirm = false).Build();

            administratorController.ModelState.AddModelError(nameof(DeactivateAdminViewModel.Confirm), expectedErrorMessage);

            // When
            var result = administratorController.DeactivateAdmin(adminUserId, deactivateViewModel);

            // Then
            result.Should().BeViewResult().WithDefaultViewName().ModelAs <DeactivateAdminViewModel>();
            administratorController.ModelState[nameof(DeactivateAdminViewModel.Confirm)].Errors[0].ErrorMessage.Should()
            .BeEquivalentTo(expectedErrorMessage);
            A.CallTo(() => userDataService.DeactivateAdmin(adminUserId)).MustNotHaveHappened();
        }