Пример #1
0
        public void Call_UserServiceUpdateUserMethodOnceWithCorrectParams()
        {
            var args        = MockedEventArgsGenerator.GetMockedUserUpdateEventArgs();
            var view        = new Mock <IManageUsersView>();
            var userService = new Mock <IUserService>();

            userService.Setup(s => s.UpdateUser(args.Id, args.Email, args.UserName, args.IsConfirmed))
            .Returns(IdentityResult.Success);

            var sut = new ManageUsersPresenter(userService.Object, view.Object);

            view.Raise(v => v.UserUpdate += null, view.Object, args);

            userService.Verify(s => s.UpdateUser(args.Id, args.Email, args.UserName, args.IsConfirmed), Times.Once);
        }
Пример #2
0
        public void Set_ViewErrorMessage_WhenResultFails()
        {
            var args        = MockedEventArgsGenerator.GetMockedUserUpdateEventArgs();
            var view        = new Mock <IManageUsersView>();
            var userService = new Mock <IUserService>();

            userService.Setup(s => s.UpdateUser(args.Id, args.Email, args.UserName, args.IsConfirmed))
            .Returns(IdentityResult.Failed());

            var sut = new ManageUsersPresenter(userService.Object, view.Object);

            view.Raise(v => v.UserUpdate += null, view.Object, args);

            view.VerifySet(v => v.ErrorMessageVisible = true);
            view.VerifySet(v => v.ErrorMessageText    = It.IsAny <string>());
        }