public void CallReviewServiceGetByIdMethodOnceWithCorrectParams() { var args = MockedEventArgsGenerator.GetIdentifiableEventArgs <int>(); var reviewService = new Mock <IBeerReviewService>(); var view = new Mock <IReviewDetailsView>(); var presenter = new DefaultPresenter(reviewService.Object, view.Object); view.Raise(v => v.OnInitialise += null, view.Object, args); reviewService.Verify(s => s.GetById(args.Id), Times.Once); }
public void Call_UserServiceRemoveAdminMethodOnceWithCorrectParams() { var args = MockedEventArgsGenerator.GetIdentifiableEventArgs <string>(); var view = new Mock <IManageUsersView>(); var userService = new Mock <IUserService>(); userService.Setup(s => s.RemoveAdmin(args.Id)) .Returns(IdentityResult.Success); var sut = new ManageUsersPresenter(userService.Object, view.Object); view.Raise(v => v.UserRemoveAdmin += null, view.Object, args); userService.Verify(s => s.RemoveAdmin(args.Id), Times.Once); }
public void Set_ViewErrorMessage_WhenResultFails() { var args = MockedEventArgsGenerator.GetIdentifiableEventArgs <string>();; var view = new Mock <IManageUsersView>(); var userService = new Mock <IUserService>(); userService.Setup(s => s.RemoveAdmin(args.Id)) .Returns(IdentityResult.Failed()); var sut = new ManageUsersPresenter(userService.Object, view.Object); view.Raise(v => v.UserRemoveAdmin += null, view.Object, args); view.VerifySet(v => v.ErrorMessageVisible = true); view.VerifySet(v => v.ErrorMessageText = It.IsAny <string>()); }
public void Set_ViewSuccessMessage_WhenResultSucceeds() { var args = MockedEventArgsGenerator.GetIdentifiableEventArgs <string>(); var view = new Mock <IManageUsersView>(); var userService = new Mock <IUserService>(); userService.Setup(s => s.DisableUser(args.Id)) .Returns(IdentityResult.Success); var sut = new ManageUsersPresenter(userService.Object, view.Object); view.Raise(v => v.UserDisable += null, view.Object, args); view.VerifySet(v => v.SuccessMessageVisible = true); view.VerifySet(v => v.SuccessMessageText = It.IsAny <string>()); }
public void SetViewProperties_WhenReviewIsNotFound() { var args = MockedEventArgsGenerator.GetIdentifiableEventArgs <int>(); var expectedId = this.Fixture.Create <int>(); var reviewService = new Mock <IBeerReviewService>(); reviewService.Setup(s => s.GetById(expectedId)) .Returns((IBeerReview)null); var view = new Mock <IReviewDetailsView>(); var presenter = new DefaultPresenter(reviewService.Object, view.Object); view.Raise(v => v.OnInitialise += null, view.Object, args); view.VerifySet(v => v.NotFoundVisible = true, Times.Once); }
public void SetViewProperties_WhenReviewIsFound() { var args = MockedEventArgsGenerator.GetIdentifiableEventArgs <int>(); var expectedBeerReview = new Mock <IBeerReview>(); var reviewService = new Mock <IBeerReviewService>(); reviewService.Setup(s => s.GetById(args.Id)) .Returns(expectedBeerReview.Object); var viewModel = new MockedBeerReviewViewModel(); var view = new Mock <IReviewDetailsView>(); view.Setup(v => v.Model).Returns(viewModel); var presenter = new DefaultPresenter(reviewService.Object, view.Object); view.Raise(v => v.OnInitialise += null, view.Object, args); view.VerifySet(v => v.NotFoundVisible = false, Times.Once); Assert.AreSame(expectedBeerReview.Object, view.Object.Model.Review); }