Esempio n. 1
0
        public void RegisterUser(string email, string password, string profileId)
        {
            Assert.ArgumentNotNullOrEmpty(email, nameof(email));
            Assert.ArgumentNotNullOrEmpty(password, nameof(password));

            var fullName = Context.Domain.GetFullName(email);

            try
            {
                Assert.IsNotNullOrEmpty(fullName, "Can't retrieve full userName");

                var user = User.Create(fullName, password);
                user.Profile.Email = email;
                if (!string.IsNullOrEmpty(profileId))
                {
                    user.Profile.ProfileItemId = profileId;
                }

                user.Profile.Save();
                this.pipelineService.RunRegistered(user);
            }
            catch
            {
                AccountTrackerService.TrackRegistrationFailed(email);
                throw;
            }

            this.Login(email, password);
        }
 public void TrackOutcome_NullOutcomeId_ThrowException([NoAutoProperties] AccountTrackerService trackerService, ITracker tracker)
 {
     tracker.IsActive.Returns(true);
     using (new TrackerSwitcher(tracker))
     {
         trackerService.Invoking(x => x.TrackOutcome(null)).ShouldThrow <ArgumentNullException>();
     }
 }
 public void IdentifyContact_ValidIdentifier_ShouldIdentifyContact([NoAutoProperties] AccountTrackerService trackerService, string contactIdentifier, ITracker tracker, [Substitute] Session session)
 {
     tracker.IsActive.Returns(true);
     tracker.Session.Returns(session);
     using (new TrackerSwitcher(tracker))
     {
         trackerService.IdentifyContact(contactIdentifier);
         tracker.Session.Received().Identify(contactIdentifier);
     }
 }
Esempio 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));
        }
Esempio n. 5
0
 public TrackLoggedIn(AccountTrackerService accountTrackerService)
 {
     this.accountTrackerService = accountTrackerService;
 }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public void TrackLogin_Call_ShouldTrackLoginGoal(string source, string identifier, [Frozen] ITrackerService trackerService, [Greedy] AccountTrackerService accountTrackerService)
        {
            //Act
            accountTrackerService.TrackLoginAndIdentifyContact(source, identifier);

            //Assert
            trackerService.Received(1).TrackGoal(AccountTrackerService.LoginGoalId, source);
            trackerService.Received(1).IdentifyContact(source, identifier);
        }
 public void TrackPageEvent_InActiveTracker_ShouldNotTrack(Database db, [Content] Item item, ITracker tracker, AccountTrackerService accountTrackerService)
 {
     using (new TrackerSwitcher(tracker))
     {
         accountTrackerService.TrackPageEvent(item.ID);
         tracker.CurrentPage.DidNotReceive().Register(Arg.Is <PageEventItem>(x => x.ID == item.ID));
     }
 }
        public void TrackLogin_Call_ShouldTrackLoginGoal(string identifier, Db db, ITracker tracker, AccountTrackerService accountTrackerService, [Substitute] Session session)
        {
            tracker.IsActive.Returns(true);
            tracker.Session.Returns(session);
            db.Add(new DbItem("Item", ConfigSettings.LoginGoalId));

            using (new TrackerSwitcher(tracker))
            {
                accountTrackerService.TrackLogin(identifier);
                tracker.CurrentPage.Received(1).Register(Arg.Is <PageEventItem>(x => x.ID == ConfigSettings.LoginGoalId));
            }
        }
 public void TrackPageEvent_NullEvent_ShouldThrowArgumentException(AccountTrackerService accountTrackerService)
 {
     accountTrackerService.Invoking(x => x.TrackPageEvent(null)).ShouldThrow <ArgumentNullException>();
 }
 public void TrackPageEvent_NullTracker_ShouldNotTrackEvent(Database db, [Content] Item item, ITracker tracker, AccountTrackerService accountTrackerService)
 {
     accountTrackerService.TrackPageEvent(item.ID);
     tracker.CurrentPage.DidNotReceive().Register(Arg.Is <PageEventItem>(x => x.ID == item.ID));
 }
 public void TrackPageEvent_ValidID_ShouldTrackById(Database db, [Content] Item item, ITracker tracker, AccountTrackerService accountTrackerService)
 {
     tracker.IsActive.Returns(true);
     using (new TrackerSwitcher(tracker))
     {
         accountTrackerService.TrackPageEvent(item.ID);
         tracker.CurrentPage.Received(1).Register(Arg.Is <PageEventItem>(x => x.ID == item.ID));
     }
 }
        public void TrackOutcome_InactiveTracker_ShouldNotTrack([Frozen] ID outcomeDefinitionId, [Frozen] IAccountsSettingsService accountsSettingsService, [NoAutoProperties] AccountTrackerService trackerService, ITracker tracker)
        {
            // Arrange
            tracker.IsActive.Returns(false);
            tracker.Session.Returns(Substitute.For <Session>());
            tracker.Session.CustomData.Returns(new Dictionary <string, object>());

            using (new TrackerSwitcher(tracker))
            {
                // Act
                trackerService.TrackOutcome(outcomeDefinitionId);

                // Assert
                tracker.GetContactOutcomes().Should().BeEmpty();
            }
        }
        public void TrackOutcome_ValidOutcome_ShouldRegisterOutcome([Frozen] ID outcomeDefinitionId, [Frozen] IAccountsSettingsService accountsSettingsService, [NoAutoProperties] AccountTrackerService trackerService, ITracker tracker, Contact contact, CurrentInteraction interaction)
        {
            tracker.IsActive.Returns(true);
            tracker.Contact.Returns(contact);
            tracker.Interaction.Returns(interaction);
            tracker.Session.Returns(Substitute.For <Session>());
            tracker.Session.CustomData.Returns(new Dictionary <string, object>());

            using (new TrackerSwitcher(tracker))
            {
                trackerService.TrackOutcome(outcomeDefinitionId);

                tracker.GetContactOutcomes().Should().Contain(o => o.DefinitionId == outcomeDefinitionId);
            }
        }
        public void TrackLogin_Call_ShouldTrackLoginGoal(string identifier, Db db, [Frozen] ITrackerService trackerService, [Greedy] AccountTrackerService accountTrackerService)
        {
            //Arrange
            db.Add(new DbItem("Item", AccountTrackerService.LoginGoalId));

            //Act
            accountTrackerService.TrackLogin(identifier);

            //Assert
            trackerService.Received().TrackPageEvent(Arg.Is <ID>(AccountTrackerService.LoginGoalId));
        }
        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);
            }
        }
        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);
        }
 public TrackRegistered()
 {
     this.accountTrackerService = new AccountTrackerService(new AccountsSettingsService(), new TrackerService());
 }