コード例 #1
0
        public void shouldGetProfileForFamilyMember()
        {
            
            Person me = new Person()
            {
                ContactId = myContactId
            };

            Person brady = new Person()
            {
                ContactId = 13579,
                NickName = "Brady"
            };

            var familyList = new List<FamilyMember>
            {
                new FamilyMember()
                {
                    Age = 52,
                    ContactId = myContactId,
                    Email = "*****@*****.**",
                    LastName = "Maddox",
                    LoggedInUser = true,
                    ParticipantId = 123456,
                    PreferredName = "Tony",
                    RelationshipId = 1
                },
                new FamilyMember()
                {
                    Age = 12,
                    ContactId = 13579,
                    LastName = "Maddox",
                    PreferredName = "Brady"
                }
            };

            _serveServiceMock.Setup(x => x.GetImmediateFamilyParticipants(_authType + " " + _authToken)).Returns(familyList);
            _personServiceMock.Setup(x => x.GetLoggedInUserProfile(_authType + " " + _authToken)).Returns(me);
            _personServiceMock.Setup(x => x.GetPerson(13579)).Returns(brady);
            
            IHttpActionResult result = _fixture.GetProfile(13579);
            Assert.IsNotNull(result);
            Assert.IsInstanceOf<OkNegotiatedContentResult<Person>>(result);
            var r = (OkNegotiatedContentResult<Person>)result;
            Assert.IsNotNull(r.Content);
            Assert.AreEqual(r.Content.ContactId, brady.ContactId);

        }
コード例 #2
0
        public void SetProfile(String token, Person person)
        {
            var contactDictionary = getDictionary(person.GetContact());
            var householdDictionary = getDictionary(person.GetHousehold());
            var addressDictionary = getDictionary(person.GetAddress());
            addressDictionary.Add("State/Region", addressDictionary["State"]);
            _contactService.UpdateContact(person.ContactId, contactDictionary, householdDictionary, addressDictionary);
            _contactAttributeService.SaveContactAttributes(person.ContactId, person.AttributeTypes, person.SingleAttributes);

            if (person.ParticipantStartDate != null)
            {
                Participant participant = _participantService.GetParticipant(person.ContactId);
                participant.ParticipantStart = person.ParticipantStartDate;
                participant.AttendanceStart = person.AttendanceStartDate;
                // convert to the object with underscores
                var p = Mapper.Map <MpParticipant>(participant);
                _participantService.UpdateParticipant(getDictionary(p));
            }
        }
コード例 #3
0
        public void SetUp()
        {
            _contactRelationshipService = new Mock<IContactRelationshipService>();
            _contactService = new Mock<IContactService>();
            _opportunityService = new Mock<IOpportunityService>();
            _authenticationService = new Mock<IAuthenticationService>();
            _personService = new Mock<crds_angular.Services.Interfaces.IPersonService>();
            _eventService = new Mock<IEventService>();
            _serveService = new Mock<IServeService>();
            _participantService = new Mock<IParticipantService>();
            _groupParticipantService = new Mock<IGroupParticipantService>();
            _groupService = new Mock<IGroupService>();
            _communicationService = new Mock<ICommunicationService>();
            _configurationWrapper = new Mock<IConfigurationWrapper>();
            _apiUserService = new Mock<IApiUserService>();
            _responseService = new Mock<IResponseService>();

            fakeOpportunity.EventTypeId = 3;
            fakeOpportunity.GroupContactId = 23;
            fakeOpportunity.GroupContactName = "Harold";
            fakeOpportunity.GroupName = "Mighty Ducks";
            fakeOpportunity.OpportunityId = 12;
            fakeOpportunity.OpportunityName = "Goalie";

            fakeGroupContact.Contact_ID = 23;
            fakeGroupContact.Email_Address = "*****@*****.**";
            fakeGroupContact.Nickname = "fakeNick";
            fakeGroupContact.Last_Name = "Name";

            fakeMyContact.Contact_ID = 8;
            fakeMyContact.Email_Address = "*****@*****.**";

            _contactService.Setup(m => m.GetContactById(1)).Returns(fakeGroupContact);
            _contactService.Setup(m => m.GetContactById(fakeOpportunity.GroupContactId)).Returns(fakeGroupContact);
            _contactService.Setup(m => m.GetContactById(8)).Returns(fakeMyContact);

            _communicationService.Setup(m => m.GetTemplate(rsvpYesId)).Returns(mockRsvpYesTemplate);
            _communicationService.Setup(m => m.GetTemplate(rsvpNoId)).Returns(mockRsvpNoTemplate);
            _communicationService.Setup(m => m.GetTemplate(rsvpChangeId)).Returns(mockRsvpChangedTemplate);


            _authenticationService.Setup(mocked => mocked.GetContactId(It.IsAny<string>())).Returns(123456);
            var myContact = new MyContact
            {
                Contact_ID = 123456,
                Email_Address = "*****@*****.**",
                Last_Name = "last-name",
                Nickname = "nickname",
                First_Name = "first-name",
                Middle_Name = "middle-name",
                Maiden_Name = "maiden-name",
                Mobile_Phone = "mobile-phone",
                Mobile_Carrier = 999,
                Date_Of_Birth = "date-of-birth",
                Marital_Status_ID = 5,
                Gender_ID = 2,
                Employer_Name = "employer-name",
                Address_Line_1 = "address-line-1",
                Address_Line_2 = "address-line-2",
                City = "city",
                State = "state",
                Postal_Code = "postal-code",                
                Foreign_Country = "foreign-country",
                Home_Phone = "home-phone",
                Congregation_ID = 8,
                Household_ID = 7,
                Address_ID = 6
            };
            _contactService.Setup(mocked => mocked.GetMyProfile(It.IsAny<string>())).Returns(myContact);

            var person = new Person();
            person.ContactId = myContact.Contact_ID;
            person.EmailAddress = myContact.Email_Address;
            person.LastName = myContact.Last_Name;
            person.NickName = myContact.Nickname;

            _personService.Setup(m => m.GetLoggedInUserProfile(It.IsAny<string>())).Returns(person);

            _fixture = new ServeService(_contactService.Object, _contactRelationshipService.Object,
                _opportunityService.Object, _eventService.Object,
                _participantService.Object, _groupParticipantService.Object, _groupService.Object,
                _communicationService.Object, _authenticationService.Object, _configurationWrapper.Object, _apiUserService.Object, _responseService.Object);

            //force AutoMapper to register
            AutoMapperConfig.RegisterMappings();
        }