Ejemplo n.º 1
0
        public void TrackRegister_Call_ShouldTrackRegistrationGoal(ID outcomeID, ITracker tracker, [Frozen] IAccountsSettingsService accountsSettingsService, [Frozen] ITrackerService trackerService, [Greedy] AccountTrackerService accountTrackerService)
        {
            // Arrange
            accountsSettingsService.GetRegistrationOutcome(Arg.Any <Item>()).Returns(outcomeID.Guid);

            //Act
            accountTrackerService.TrackRegistration();

            //Assert
            trackerService.Received(1).TrackGoal(AccountTrackerService.RegistrationGoalId);
            trackerService.Received(1).TrackOutcome(outcomeID.Guid);
        }
        public void TrackRegister_Call_ShouldTrackRegistrationGoal(Db db, ID outcomeID, ITracker tracker, [Frozen] IAccountsSettingsService accountsSettingsService, [Frozen] ITrackerService trackerService, [Greedy] AccountTrackerService accountTrackerService)
        {
            // Arrange
            accountsSettingsService.GetRegistrationOutcome(Arg.Any <Item>()).Returns(outcomeID);

            db.Add(new DbItem("Item", AccountTrackerService.RegistrationGoalId));
            db.Add(new DbItem("Item", AccountTrackerService.LoginGoalId));

            //Act
            accountTrackerService.TrackRegistration();

            //Assert
            trackerService.Received().TrackPageEvent(AccountTrackerService.RegistrationGoalId);
            trackerService.Received().TrackOutcome(outcomeID);
        }
Ejemplo n.º 3
0
        public void TrackRegister_Call_ShouldTrackRegistrationGoal(Db db, ID outcomeID, ITracker tracker, [Frozen] IAccountsSettingsService accountsSettingsService, AccountTrackerService accountTrackerService)
        {
            // Arrange
            tracker.IsActive.Returns(true);
            tracker.Contact.Returns(Substitute.For <Contact>());
            tracker.Interaction.Returns(Substitute.For <CurrentInteraction>());
            tracker.Session.Returns(Substitute.For <Session>());
            tracker.Session.CustomData.Returns(new Dictionary <string, object>());

            accountsSettingsService.GetRegistrationOutcome(Arg.Any <Item>()).Returns(outcomeID);

            db.Add(new DbItem("Item", ConfigSettings.RegistrationGoalId));
            db.Add(new DbItem("Item", ConfigSettings.LoginGoalId));

            using (new TrackerSwitcher(tracker))
            {
                accountTrackerService.TrackRegistration();
                tracker.CurrentPage.Received(1).Register(Arg.Is <PageEventItem>(x => x.ID == ConfigSettings.RegistrationGoalId));
                tracker.GetContactOutcomes().Should().Contain(o => o.DefinitionId == outcomeID);
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult UpdateProfile([FromBody] UpdateProfileViewModel vm)
        {
            // fills profile
            EditProfile profile = new EditProfile
            {
                FirstName = vm.FirstName,
                Gender    = vm.Gender,
            };

            // if profile name is provided and this name is not know yet, set new profile is true
            var newProfile = false;

            if (!String.IsNullOrEmpty(vm.FirstName) && String.IsNullOrEmpty(contactProfileProvider.PersonalInfo.FirstName))
            {
                newProfile = true;
            }

            // update profile
            IContactProfileService service = new ContactProfileService();

            service.SetProfile(profile);

            // if new profile and profile has been set, set new outcome for the experience profile timeline
            if (newProfile && !String.IsNullOrEmpty(contactProfileProvider.PersonalInfo.FirstName))
            {
                var accountTrackerService = new AccountTrackerService(new AccountsSettingsService(), new TrackerService());
                accountTrackerService.TrackRegistration();
                contactProfileProvider.Flush();
            }

            //todo: change to something meaningful. Important, not urgent
            Response response = new Response();

            response.Test = $"profile updated";
            return(new JsonResult <Response>(response, new JsonSerializerSettings(), Encoding.UTF8, this));
        }