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

            AssertMessageSuccess(messageBuildResult, Token, Event, DistinctId);
        }
コード例 #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));
        }
コード例 #3
0
        public void When_DistinctIdParameter_Then_DistinctIdSetInMessage()
        {
            MessageBuildResult messageBuildResult =
                TrackMessageBuilder.Build(Token, Event, null, null, DistinctId, null);

            AssertMessageSuccess(messageBuildResult, Token, Event, DistinctId);
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #8
0
 public void SetUp()
 {
     MixpanelConfig.Global.Reset();
     _builder = new TrackMessageBuilder();
     _md      = new MessageData(
         _builder.SpecialPropsBindings,
         _builder.DistinctIdPropsBindings,
         _builder.MessagePropetiesRules,
         _builder.SuperPropertiesRules);
 }
コード例 #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));
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #12
0
        public void When_NoEvent_Then_MessageBuildFails()
        {
            MessageBuildResult messageBuildResult = TrackMessageBuilder.Build(Token, null, null, null, null, null);

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