public void ShouldCallGetUserByIdMethodFromUsersService(int statusType, string id) { // Arrange var contact = new Contact(); var mockedView = new Mock <IContactDetailedView>(); mockedView.Setup(v => v.Model).Returns(new ContactDetailedViewModel()); var mockedContactsService = new Mock <IContactsService>(); var mockedUsersService = new Mock <IUsersService>(); mockedUsersService.Setup(us => us.GetUserById(It.IsAny <string>())).Verifiable(); var contactDetailedPresenter = new ContactDetailedPresenter(mockedView.Object, mockedContactsService.Object, mockedUsersService.Object); // Act mockedView.Raise(v => v.EdittingContactStatus += null, new EditContactStatusEventArgs(contact, statusType, id)); // Assert mockedUsersService.Verify(us => us.GetUserById(id), Times.Once); }
public void ShouldSetViewModelWithContact_ReceivedByGetContactByIdMethodFromContactsService(int id) { // Arrange var contact = new Contact() { Id = id }; var mockedView = new Mock <IContactDetailedView>(); mockedView.Setup(v => v.Model).Returns(new ContactDetailedViewModel()); var mockedContactsService = new Mock <IContactsService>(); mockedContactsService.Setup(cs => cs.GetContactById(It.IsAny <int>())) .Returns(contact) .Verifiable(); var mockedUsersService = new Mock <IUsersService>(); var contactDetailedPresenter = new ContactDetailedPresenter(mockedView.Object, mockedContactsService.Object, mockedUsersService.Object); // Act mockedView.Raise(v => v.Initial += null, new GetContactByIdEventArgs(id)); // Assert Assert.AreEqual(contact, mockedView.Object.Model.Contact); }
public void ShouldCreateAnInstanceInheritingPresenter_WhenValidContacsServiceAndUsersServiceArePassed() { // Arrange var mockedView = new Mock <IContactDetailedView>(); var mockedContactsService = new Mock <IContactsService>(); var mockedUsersService = new Mock <IUsersService>(); // Act var contactDetailedPresenter = new ContactDetailedPresenter(mockedView.Object, mockedContactsService.Object, mockedUsersService.Object); // Assert Assert.IsInstanceOf <Presenter <IContactDetailedView> >(contactDetailedPresenter); }
public void ShouldSubscribeToContactDetailedViewOnEdittingContactStatusEvent() { // Arrange var mockedView = new MockedContactDetailedView(); var mockedContactsService = new Mock <IContactsService>(); var mockedUsersService = new Mock <IUsersService>(); // Act var contactDetailedPresenter = new ContactDetailedPresenter(mockedView, mockedContactsService.Object, mockedUsersService.Object); // Assert Assert.IsTrue(mockedView.IsSubscribedMethod("OnEdittingContactStatus")); }
public void ShouldCallGetContactByIdMethodFromContactsService(int id) { // Arrange var mockedView = new Mock <IContactDetailedView>(); mockedView.Setup(v => v.Model).Returns(new ContactDetailedViewModel()); var mockedContactsService = new Mock <IContactsService>(); mockedContactsService.Setup(cs => cs.GetContactById(It.IsAny <int>())).Verifiable(); var mockedUsersService = new Mock <IUsersService>(); var contactDetailedPresenter = new ContactDetailedPresenter(mockedView.Object, mockedContactsService.Object, mockedUsersService.Object); // Act mockedView.Raise(v => v.Initial += null, new GetContactByIdEventArgs(id)); // Assert mockedContactsService.Verify(cs => cs.GetContactById(id), Times.Once); }