Exemplo n.º 1
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));
            }
        }
Exemplo n.º 2
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));
            }
        }