Ejemplo n.º 1
0
        public void TrackOutcome_ValidOutcome_ShouldRegisterOutcome([Frozen] ID outcomeDefinitionId, [NoAutoProperties] TrackerService 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);
            }
        }
Ejemplo n.º 2
0
        public void TrackOutcome_InactiveTracker_ShouldNotTrack([Frozen] ID outcomeDefinitionId, [NoAutoProperties] TrackerService 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();
            }
        }
Ejemplo n.º 3
0
        public void TrackOutcome_InactiveTracker_ShouldNotTrack([Frozen] ID outcomeDefinitionId, [NoAutoProperties] TrackerService 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.ToGuid());

                // Assert
                tracker.CurrentPage.DidNotReceiveWithAnyArgs().RegisterOutcome(Arg.Any <IOutcomeDefinition>(), Arg.Any <string>(), Arg.Any <decimal>());
            }
        }
Ejemplo n.º 4
0
        public void TrackOutcome_ValidOutcome_ShouldRegisterOutcome([Frozen] Guid outcomeDefinitionId, TrackerService trackerService, ITracker tracker, Contact contact, IOutcomeDefinition outcome)
        {
            // Arrange
            tracker.IsActive.Returns(true);
            tracker.Contact.Returns(contact);
            trackerService.OutcomeDefinitionManager.Get(Arg.Any <Guid>(), Arg.Any <CultureInfo>()).Returns(info =>
            {
                outcome.Id.Returns((Guid)info[0]);
                return(outcome);
            });

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

                // Assert
                tracker.CurrentPage.Received(1).RegisterOutcome(Arg.Is <IOutcomeDefinition>(x => x.Id == outcomeDefinitionId), Arg.Any <string>(), Arg.Any <decimal>());
            }
        }