コード例 #1
0
        public void SaveCustomPropertiesLog()
        {
            var addedLog = new CustomPropertiesLog
            {
                Device     = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(),
                Toffset    = TimeHelper.CurrentTimeInMilliseconds(),
                Properties = new Dictionary <string, object>
                {
                    { "t1", "test" },
                    { "t2", new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) },
                    { "t3", 1 },
                    { "t4", 0.1f },
                    { "t5", false },
                    { "t6", null }
                },
                Sid = Guid.NewGuid()
            };

            var storage = new Mobile.Storage.Storage();

            storage.DeleteLogsAsync(StorageTestChannelName).RunNotAsync();
            storage.PutLogAsync(StorageTestChannelName, addedLog).RunNotAsync();
            var retrievedLogs = new List <Log>();

            storage.GetLogsAsync(StorageTestChannelName, 1, retrievedLogs).RunNotAsync();
            var retrievedLog = retrievedLogs[0] as CustomPropertiesLog;

            foreach (var addedProperty in addedLog.Properties)
            {
                object retrievedProperty;
                Assert.IsTrue(retrievedLog.Properties.TryGetValue(addedProperty.Key, out retrievedProperty));
                Assert.IsTrue(EqualityComparer <object> .Default.Equals(addedProperty.Value, retrievedProperty));
            }
        }
コード例 #2
0
        public void CheckInitialValues()
        {
            var log = new CustomPropertiesLog();

            Assert.IsNull(log.Device);
            Assert.AreEqual(0, log.Properties.Count);
            Assert.IsNull(log.Sid);
            Assert.AreEqual(0, log.Toffset);
        }
コード例 #3
0
        public void ValidateStartServiceLog()
        {
            var log = new CustomPropertiesLog
            {
                Properties = null,
                Device     = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(),
                Toffset    = TimeHelper.CurrentTimeInMilliseconds()
            };

            Assert.ThrowsException <Rest.ValidationException>((Action)log.Validate);
        }
        public void ValidateStartServiceLog()
        {
            var log = new CustomPropertiesLog
            {
                Properties = null,
                Device     = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(),
                Timestamp  = DateTime.Now
            };

            Assert.ThrowsException <ValidationException>((Action)log.Validate);
        }
コード例 #5
0
        private void SetInstanceCustomProperties(CustomProperties customProperties)
        {
            if (customProperties == null || customProperties.Properties.Count == 0)
            {
                MobileCenterLog.Error(MobileCenterLog.LogTag, "Custom properties may not be null or empty");
                return;
            }
            var customPropertiesLog = new CustomPropertiesLog();

            customPropertiesLog.Properties = customProperties.Properties;
            _channel.Enqueue(customPropertiesLog);
        }
コード例 #6
0
        private void SetInstanceCustomProperties(CustomProperties customProperties)
        {
            if (!Configured)
            {
                MobileCenterLog.Error(MobileCenterLog.LogTag, "Mobile Center hasn't been configured. You need to call MobileCenter.Start with appSecret or MobileCenter.Configure first.");
                return;
            }
            if (customProperties == null || customProperties.Properties.Count == 0)
            {
                MobileCenterLog.Error(MobileCenterLog.LogTag, "Custom properties may not be null or empty");
                return;
            }
            var customPropertiesLog = new CustomPropertiesLog();

            customPropertiesLog.Properties = customProperties.Properties;
            _channel.EnqueueAsync(customPropertiesLog);
        }