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)); } }
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); }
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); }