コード例 #1
0
        public void TestManagerMultipleInstance()
        {
            string appID1 = Guid.NewGuid().ToString();
            string appID2 = Guid.NewGuid().ToString();
            string appID3 = Guid.NewGuid().ToString();

            MobileAnalyticsManager manager1 = MobileAnalyticsManager.GetOrCreateInstance(appID1, Credentials, RegionEndpoint.USEast1, new MobileAnalyticsManagerConfig());
            MobileAnalyticsManager manager2 = MobileAnalyticsManager.GetOrCreateInstance(appID2, Credentials, RegionEndpoint.USEast1, new MobileAnalyticsManagerConfig());
            MobileAnalyticsManager manager3 = MobileAnalyticsManager.GetOrCreateInstance(appID3, Credentials, RegionEndpoint.USEast1, new MobileAnalyticsManagerConfig());

            var    type1                = manager1.GetType();
            var    property1            = type1.GetProperty("ClientContext", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            var    clientContext1       = property1.GetValue(manager1, null) as ClientContext;
            string clientContextString1 = clientContext1.ToJsonString();

            var    type2                = manager2.GetType();
            var    property2            = type2.GetProperty("ClientContext", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            var    clientContext2       = property2.GetValue(manager2, null) as ClientContext;
            string clientContextString2 = clientContext2.ToJsonString();

            var    type3                = manager3.GetType();
            var    property3            = type3.GetProperty("ClientContext", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            var    clientContext3       = property3.GetValue(manager3, null) as ClientContext;
            string clientContextString3 = clientContext3.ToJsonString();

            Assert.IsTrue(clientContextString1.IndexOf(appID1) > 0);
            Assert.IsTrue(clientContextString2.IndexOf(appID2) > 0);
            Assert.IsTrue(clientContextString3.IndexOf(appID3) > 0);
        }
コード例 #2
0
        public void TestManagerAddClientContextCustomAttribute()
        {
            string KEY1   = Guid.NewGuid().ToString();
            string KEY2   = Guid.NewGuid().ToString();
            string VALUE1 = Guid.NewGuid().ToString();
            string VALUE2 = Guid.NewGuid().ToString();
            string appID  = Guid.NewGuid().ToString();

            MobileAnalyticsManager manager = MobileAnalyticsManager.GetOrCreateInstance(appID, Credentials, RegionEndpoint.USEast1, new MobileAnalyticsManagerConfig());

            manager.AddCustomAttributeToClientContext(KEY1, VALUE1);
            manager.AddCustomAttributeToClientContext(KEY2, VALUE2);

            var    type                = manager.GetType();
            var    property            = type.GetProperty("ClientContext", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            var    clientContext       = property.GetValue(manager, null) as ClientContext;
            string clientContextString = clientContext.ToJsonString();

            Assert.IsTrue(clientContextString.IndexOf("custom") > 0);
            Assert.IsTrue(clientContextString.IndexOf(KEY1) > 0);
            Assert.IsTrue(clientContextString.IndexOf(KEY2) > 0);
            Assert.IsTrue(clientContextString.IndexOf(VALUE1) > 0);
            Assert.IsTrue(clientContextString.IndexOf(VALUE2) > 0);

            Assert.IsTrue(clientContextString.IndexOf("custom") < clientContextString.IndexOf(KEY1));
            Assert.IsTrue(clientContextString.IndexOf("custom") < clientContextString.IndexOf(KEY2));
            Assert.IsTrue(clientContextString.IndexOf(KEY1) < clientContextString.IndexOf(VALUE1));
            Assert.IsTrue(clientContextString.IndexOf(KEY2) < clientContextString.IndexOf(VALUE2));
        }