Beispiel #1
0
        public void When_DistinctIdFromRawProperties_Then_DistinctIdSetInMessage()
        {
            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, null, new { DistinctId }, null, null);

            AssertMessageSuccess(messageBuildResult, Token, Event, DistinctId);
        }
Beispiel #2
0
        public void When_SuperPropertiesAndRawProperties_Then_RawPropertiesOverwriteSuperProperties()
        {
            var superProperties = CreateSuperProperties(
                // Must be overwritten by message property
                ObjectProperty.Default(StringPropertyName2, PropertyOrigin.SuperProperty, StringPropertyValue2 + "-Super"),
                ObjectProperty.Default(IntPropertyName, PropertyOrigin.SuperProperty, IntPropertyValue));

            var rawProperties = new Dictionary <string, object>
            {
                { StringPropertyName, StringPropertyValue },
                { StringPropertyName2, StringPropertyValue2 },
                { DecimalPropertyName, DecimalPropertyValue }
            };


            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, superProperties, rawProperties, DistinctId, null);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId,
                new KeyValuePair <string, object>(StringPropertyName, StringPropertyValue),
                new KeyValuePair <string, object>(StringPropertyName2, StringPropertyValue2),
                new KeyValuePair <string, object>(DecimalPropertyName, DecimalPropertyValue),
                new KeyValuePair <string, object>(IntPropertyName, IntPropertyValue));
        }
Beispiel #3
0
        public void When_DistinctIdParameter_Then_DistinctIdSetInMessage()
        {
            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, null, null, DistinctId, null);

            AssertMessageSuccess(messageBuildResult, Token, Event, DistinctId);
        }
Beispiel #4
0
        public void When_NameFormattingConfigured_Then_FormattingAppliedToPropertyNames()
        {
            var config = new MixpanelConfig {
                MixpanelPropertyNameFormat = MixpanelPropertyNameFormat.TitleCase
            };

            var superProperties = CreateSuperProperties(
                // Must be overwritten by message property
                ObjectProperty.Default("PropertyA", PropertyOrigin.SuperProperty, 10),
                ObjectProperty.Default("PropertyC", PropertyOrigin.SuperProperty, 3));

            var rawProperties = new
            {
                PropertyA = 1,
                PropertyB = 2
            };

            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, superProperties, rawProperties, DistinctId, config);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId,
                new KeyValuePair <string, object>("Property A", 1),
                new KeyValuePair <string, object>("Property B", 2),
                new KeyValuePair <string, object>("Property C", 3));
        }
Beispiel #5
0
        public void When_PredefinedPropertiesUsed_Then_AllPropertiesInMessage()
        {
            var rawProperties = new Dictionary <string, object>
            {
                { MixpanelProperty.DistinctId, DistinctId },
                { MixpanelProperty.Time, Time },
                { MixpanelProperty.Ip, Ip },
                { MixpanelProperty.Duration, Duration },
                { MixpanelProperty.Os, Os },
                { MixpanelProperty.ScreenWidth, ScreenWidth },
                { MixpanelProperty.ScreenHeight, ScreenHeight }
            };

            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, null, rawProperties, null, null);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId,
                new KeyValuePair <string, object>(TrackSpecialProperty.Time, TimeUnix),
                new KeyValuePair <string, object>(TrackSpecialProperty.Ip, Ip),
                new KeyValuePair <string, object>(TrackSpecialProperty.Duration, DurationSeconds),
                new KeyValuePair <string, object>(TrackSpecialProperty.Os, Os),
                new KeyValuePair <string, object>(TrackSpecialProperty.ScreenWidth, ScreenWidth),
                new KeyValuePair <string, object>(TrackSpecialProperty.ScreenHeight, ScreenHeight));
        }
Beispiel #6
0
        public void When_AllSpecialProperties_Then_AllPropertiesInMessage()
        {
            var rawProperties = new
            {
                DistinctId,
                Time,
                Ip,
                Duration,
                Os,
                ScreenWidth,
                ScreenHeight
            };

            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, null, rawProperties, null, null);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId,
                new KeyValuePair <string, object>(TrackSpecialProperty.Time, TimeUnix),
                new KeyValuePair <string, object>(TrackSpecialProperty.Ip, Ip),
                new KeyValuePair <string, object>(TrackSpecialProperty.Duration, DurationSeconds),
                new KeyValuePair <string, object>(TrackSpecialProperty.Os, Os),
                new KeyValuePair <string, object>(TrackSpecialProperty.ScreenWidth, ScreenWidth),
                new KeyValuePair <string, object>(TrackSpecialProperty.ScreenHeight, ScreenHeight));
        }
Beispiel #7
0
        public void When_DistinctIdFromSuperProperties_Then_DistinctIdSetInMessage()
        {
            var superProperties = CreateSuperProperties(
                ObjectProperty.Default(DistinctIdPropertyName, PropertyOrigin.SuperProperty, SuperDistinctId));

            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, superProperties, null, null, null);

            AssertMessageSuccess(messageBuildResult, Token, Event, SuperDistinctId);
        }
Beispiel #8
0
 public void SetUp()
 {
     MixpanelConfig.Global.Reset();
     _builder = new TrackMessageBuilder();
     _md      = new MessageData(
         _builder.SpecialPropsBindings,
         _builder.DistinctIdPropsBindings,
         _builder.MessagePropetiesRules,
         _builder.SuperPropertiesRules);
 }
Beispiel #9
0
        public void When_SuperProperties_Then_AllPropertiesInMessage()
        {
            var superProperties = CreateSuperProperties(
                ObjectProperty.Default(StringPropertyName, PropertyOrigin.SuperProperty, StringPropertyValue),
                ObjectProperty.Default(DecimalPropertyName, PropertyOrigin.SuperProperty, DecimalPropertyValue));

            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, superProperties, null, DistinctId, null);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId,
                new KeyValuePair <string, object>(StringPropertyName, StringPropertyValue),
                new KeyValuePair <string, object>(DecimalPropertyName, DecimalPropertyValue));
        }
Beispiel #10
0
        public void When_TokenFromRawProperties_Then_TokenSetInMessage()
        {
            var rawProperties = new
            {
                Token,
                DistinctId
            };

            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(null, Event, null, rawProperties, null, null);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId);
        }
Beispiel #11
0
        public void When_RawProperties_Then_AllPropertiesInMessage()
        {
            var rawProperties = new Dictionary <string, object>
            {
                { StringPropertyName, StringPropertyValue },
                { IntPropertyName, IntPropertyValue },
                { DecimalPropertyName, DecimalPropertyArray }
            };

            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, null, rawProperties, DistinctId, null);

            AssertMessageSuccess(
                messageBuildResult,
                Token,
                Event,
                DistinctId,
                new KeyValuePair <string, object>(StringPropertyName, StringPropertyValue),
                new KeyValuePair <string, object>(IntPropertyName, IntPropertyValue),
                new KeyValuePair <string, object>(DecimalPropertyName, DecimalPropertyArray));
        }
Beispiel #12
0
        public void When_NoEvent_Then_MessageBuildFails()
        {
            MessageBuildResult messageBuildResult = TrackMessageBuilder.Build(Token, null, null, null, null, null);

            AssertMessageFail(messageBuildResult);
        }
Beispiel #13
0
 private MessageBuildResult BuildTrackMessage(
     string @event, object distinctId, object properties)
 {
     return(TrackMessageBuilder.Build(
                token, @event, superProperties, properties, distinctId, config));
 }