Beispiel #1
0
 public ContactByIdQueryHandlerShould()
 {
     _sut     = new ContactByIdQueryHandler(Context);
     _message = new ContactByIdQuery {
         ContactId = ContactId
     };
 }
Beispiel #2
0
 public SyncController(MyJobLeadsDbContext context,
                       ContactByIdQuery contactByIdQuery,
                       EditContactCommand editContactCmd,
                       IProcess <GetJigsawContactDetailsParams, ExternalContactSearchResultsViewModel.ContactResultViewModel> getJsContactProc)
 {
     _context          = context;
     _contactByIdQuery = contactByIdQuery;
     _editContactCmd   = editContactCmd;
     _getJsContactProc = getJsContactProc;
 }
Beispiel #3
0
        public virtual ActionResult Edit(int id)
        {
            var contact = new ContactByIdQuery(_unitOfWork, _contactAuthProcess).RequestedByUserId(CurrentUserId).WithContactId(id).Execute();

            if (contact == null)
            {
                ViewBag.EntityType = "Contact";
                return(View(MVC.Shared.Views.EntityNotFound));
            }

            var model = new EditContactViewModel(contact);

            return(View(model));
        }
Beispiel #4
0
        public void Execute_Returns_Null_Contact_When_Id_Not_Found()
        {
            // Setup
            InitializeTestEntities();
            var authMock = new Mock <IProcess <ContactAutorizationParams, AuthorizationResultViewModel> >();

            authMock.Setup(x => x.Execute(It.IsAny <ContactAutorizationParams>())).Returns(new AuthorizationResultViewModel {
                UserAuthorized = true
            });

            int id = _contact2.Id + 100;

            // Act
            Contact result = new ContactByIdQuery(_unitOfWork, authMock.Object).WithContactId(id).Execute();

            // Verify
            Assert.IsNull(result, "Query returned a non-null contact");
        }
Beispiel #5
0
        public void Can_Retrieve_Contact_By_Id()
        {
            // Setup
            InitializeTestEntities();
            var authMock = new Mock <IProcess <ContactAutorizationParams, AuthorizationResultViewModel> >();

            authMock.Setup(x => x.Execute(It.IsAny <ContactAutorizationParams>())).Returns(new AuthorizationResultViewModel {
                UserAuthorized = true
            });

            // Act
            Contact result = new ContactByIdQuery(_unitOfWork, authMock.Object).WithContactId(_contact2.Id).Execute();

            // Verify
            Assert.IsNotNull(result, "Query returned a null contact");
            Assert.AreEqual(_contact2.Id, result.Id, "Returned contact had an incorrect id value");
            Assert.AreEqual(_contact2.Name, result.Name, "Returned contact had an incorrect name value");
        }
Beispiel #6
0
        public void Execute_Returns_Null_Contact_When_User_Not_Authorized()
        {
            // Setup
            InitializeTestEntities();
            var authMock = new Mock <IProcess <ContactAutorizationParams, AuthorizationResultViewModel> >();

            authMock.Setup(x => x.Execute(It.IsAny <ContactAutorizationParams>())).Returns(new AuthorizationResultViewModel {
                UserAuthorized = false
            });

            // Act
            Contact result = new ContactByIdQuery(_unitOfWork, authMock.Object)
                             .WithContactId(_contact2.Id)
                             .RequestedByUserId(15)
                             .Execute();

            // Verify
            Assert.IsNull(result, "Query returned a non-null contact");
            authMock.Verify(x => x.Execute(It.Is <ContactAutorizationParams>(y => y.RequestingUserId == 15)));
        }