public void SaveCustomPropertiesLog()
        {
            var addedLog = new CustomPropertyLog
            {
                Device     = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(),
                Timestamp  = DateTime.Now,
                Properties = new List <CustomProperty>
                {
                    new StringProperty("t1", "test"),
                    new DateTimeProperty("t2", new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)),
                    new NumberProperty("t3", (long)1),
                    new NumberProperty("t4", 0.1),
                    new BooleanProperty("t5", false),
                    new ClearProperty("t6")
                },
                Sid = Guid.NewGuid()
            };

            var storage = new Microsoft.AppCenter.Storage.Storage();

            storage.DeleteLogs(StorageTestChannelName);
            storage.PutLog(StorageTestChannelName, addedLog);
            var retrievedLogs = new List <Log>();

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

            foreach (var addedProperty in addedLog.Properties)
            {
                var retrievedProperty = GetPropertyWithName(retrievedLog.Properties, addedProperty.Name);
                Assert.IsNotNull(retrievedProperty);
                Assert.AreEqual(addedProperty.GetValue(), retrievedProperty.GetValue());
            }
        }
        public void SaveStartServiceLog()
        {
            var addedLog = new StartServiceLog
            {
                Device    = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(),
                Timestamp = DateTime.Now,
                Services  = new List <string> {
                    "Service0", "Service1", "Service2"
                },
                Sid = Guid.NewGuid()
            };

            var storage = new Microsoft.AppCenter.Storage.Storage();

            storage.DeleteLogs(StorageTestChannelName);
            storage.PutLog(StorageTestChannelName, addedLog);
            var retrievedLogs = new List <Log>();

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

            foreach (var serviceName in addedLog.Services)
            {
                Assert.IsTrue(retrievedLog.Services.Contains(serviceName));
            }
        }
Example #3
0
        public void SaveStartServiceLog()
        {
            Constants.AppCenterDatabasePath = "temp.db";
            if (System.IO.File.Exists(Constants.AppCenterDatabasePath))
            {
                try
                {
                    System.IO.File.Delete(Constants.AppCenterDatabasePath);
                }
                catch
                {
                    // ignored
                }
            }
            var addedLog = new StartServiceLog
            {
                Device    = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(),
                Timestamp = DateTime.Now,
                Services  = new List <string> {
                    "Service0", "Service1", "Service2"
                },
                Sid = Guid.NewGuid()
            };
            var storage = new Microsoft.AppCenter.Storage.Storage();

            storage.DeleteLogs(StorageTestChannelName);
            storage.PutLog(StorageTestChannelName, addedLog);
            var retrievedLogs = new List <Log>();

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

            foreach (var serviceName in addedLog.Services)
            {
                Assert.IsTrue(retrievedLog.Services.Contains(serviceName));
            }
        }
Example #4
0
        public void PutOneLog()
        {
            var addedLog = TestLog.CreateTestLog();

            _storage.PutLog(StorageTestChannelName, addedLog);
            var retrievedLogs = new List <Log>();

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

            Assert.AreEqual(addedLog, retrievedLog);
        }