Ejemplo n.º 1
0
        public void CreateNewConfiguration()
        {
            DeleteConfig();

            var client = new ExceptionlessClient();
            LocalConfigurationDictionary localConfiguration = LocalConfigurationDictionary.Create(DEFAULT_STORE, client);

            Assert.NotNull(localConfiguration);
            Assert.False(localConfiguration.IsDirty);
            Assert.NotEqual(Guid.Empty, localConfiguration.InstallIdentifier);

            using (var store = new IsolatedStorageDirectory(DEFAULT_STORE)) {
                Assert.True(store.FileExists(CONFIG_FILENAME));
                Console.WriteLine(store.ReadFileAsString(CONFIG_FILENAME));
            }
        }
Ejemplo n.º 2
0
        public void ReadExistingConfiguration()
        {
            Assert.False(String.IsNullOrEmpty(DEFAULT_STORE));
            var logAccessor = new NullExceptionlessLogAccessor();

            LocalConfigurationDictionary localConfiguration = LocalConfigurationDictionary.Create(DEFAULT_STORE, logAccessor);

            localConfiguration.EmailAddress = "*****@*****.**";
            localConfiguration.Save();

            localConfiguration = LocalConfigurationDictionary.Create(DEFAULT_STORE, logAccessor);
            Assert.NotNull(localConfiguration);
            Assert.False(localConfiguration.IsDirty);
            Assert.NotEqual(Guid.Empty, localConfiguration.InstallIdentifier);
            Assert.Equal("*****@*****.**", localConfiguration.EmailAddress);
        }
Ejemplo n.º 3
0
        public void IsDirtyTests()
        {
            DeleteConfig();

            var client = new ExceptionlessClient();
            LocalConfigurationDictionary localConfiguration = LocalConfigurationDictionary.Create(DEFAULT_STORE, client);

            Assert.NotNull(localConfiguration);

            Assert.False(localConfiguration.IsDirty);
            localConfiguration.StartCount++;

            Assert.True(localConfiguration.IsDirty); // TODO: this fails because of line 63 in ObservableConcurrentDictionary. It fails to fire the event in real time.

            Assert.True(localConfiguration.Save());
            Assert.False(localConfiguration.IsDirty);
        }
Ejemplo n.º 4
0
        public void ReadCorruptedConfiguration()
        {
            Assert.False(String.IsNullOrEmpty(DEFAULT_STORE));
            var client = new ExceptionlessClient();

            using (var dir = new IsolatedStorageDirectory(DEFAULT_STORE))
                dir.WriteFile(CONFIG_FILENAME, "<blah/>>>");

            Exception exception = Record.Exception(() => {
                client.IsConfigurationUpdateNeeded();

                LocalConfigurationDictionary localConfiguration = LocalConfigurationDictionary.Create(DEFAULT_STORE, client);
                Assert.NotNull(localConfiguration);
            });

            Assert.Null(exception);
        }
Ejemplo n.º 5
0
        public void MultiThreadedSaveLocalConfiguration()
        {
            DeleteConfig();
            var client = new ExceptionlessClient();

            Parallel.For(0, 200, i => {
                Exception exception = Record.Exception(() => {
                    LocalConfigurationDictionary localConfiguration = LocalConfigurationDictionary.Create(DEFAULT_STORE, client);
                    Assert.NotNull(localConfiguration);

                    localConfiguration.IsDirty            = true;
                    localConfiguration["ExpireTokenDate"] = DateTime.Now.AddMinutes(i).ToString();
                    localConfiguration.StartCount++;
                    Task.Factory.StartNew(() => localConfiguration["ExpireTokenDate"] = DateTime.Now.AddMinutes(i + 1).ToString());
                    localConfiguration.Save();

                    Assert.NotNull(LocalConfigurationDictionary.Create(DEFAULT_STORE, client));

                    localConfiguration.IsDirty            = true;
                    localConfiguration["ExpireTokenDate"] = DateTime.Now.AddMinutes(i).ToString();
                    Task.Factory.StartNew(() => localConfiguration.Remove("ExpireTokenDate"));
                    localConfiguration.Save();

                    Assert.NotNull(LocalConfigurationDictionary.Create(DEFAULT_STORE, client));

                    localConfiguration.StartCount++;
                    localConfiguration.IsDirty = true;
                    Assert.True(localConfiguration.Save(), "Saved");

                    Assert.NotNull(LocalConfigurationDictionary.Create(DEFAULT_STORE, client));
                });

                Assert.Null(exception);
            });

            using (var store = new IsolatedStorageDirectory(DEFAULT_STORE)) {
                Console.WriteLine(store.GetFullPath(CONFIG_FILENAME));
                Assert.True(store.FileExists(CONFIG_FILENAME));
                Console.WriteLine(store.ReadFileAsString(CONFIG_FILENAME));
            }
        }