public async Task StoresCredentialForKeyAndGitKey() { using (var credentialCache = new CredentialCache()) { try { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(nameof(StoresCredentialForKeyAndGitKey), credential); var retrieved = await credentialCache.GetObject<Tuple<string, string>>(nameof(StoresCredentialForKeyAndGitKey)); Assert.Equal("somebody", retrieved.Item1); Assert.Equal("somebody's secret", retrieved.Item2); var retrieved2 = await credentialCache.GetObject<Tuple<string, string>>("git:" + nameof(StoresCredentialForKeyAndGitKey)); Assert.Equal("somebody", retrieved2.Item1); Assert.Equal("somebody's secret", retrieved2.Item2); } finally { try { await credentialCache.Invalidate(nameof(StoresCredentialForKeyAndGitKey)); } catch (Exception) { } } } }
public async Task RetrievesValueWithAlternateKeys() { const string key = nameof(RetrievesValueWithAlternateKeys); using (var credentialCache = new CredentialCache()) { try { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(key, credential); var retrieved = await credentialCache.GetObject<Tuple<string, string>>(key); Assert.Equal("somebody", retrieved.Item1); Assert.Equal("somebody's secret", retrieved.Item2); var retrieved2 = await credentialCache.GetObject<Tuple<string, string>>("git:" + key + "/"); Assert.Equal("somebody", retrieved2.Item1); Assert.Equal("somebody's secret", retrieved2.Item2); var retrieved3 = await credentialCache.GetObject<Tuple<string, string>>("login:"******"/"); Assert.Equal("somebody", retrieved3.Item1); Assert.Equal("somebody's secret", retrieved3.Item2); } finally { await credentialCache.Invalidate(key); } } }
public async Task StoresCredentialForKeyAndGitKey() { using (var credentialCache = new CredentialCache()) { try { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(nameof(StoresCredentialForKeyAndGitKey), credential); var retrieved = await credentialCache.GetObject <Tuple <string, string> >(nameof(StoresCredentialForKeyAndGitKey)); Assert.Equal("somebody", retrieved.Item1); Assert.Equal("somebody's secret", retrieved.Item2); var retrieved2 = await credentialCache.GetObject <Tuple <string, string> >("git:" + nameof(StoresCredentialForKeyAndGitKey)); Assert.Equal("somebody", retrieved2.Item1); Assert.Equal("somebody's secret", retrieved2.Item2); } finally { try { await credentialCache.Invalidate(nameof(StoresCredentialForKeyAndGitKey)); } catch (Exception) { } } } }
public async Task RetrievesValueWithAlternateKeys() { const string key = nameof(RetrievesValueWithAlternateKeys); using (var credentialCache = new CredentialCache()) { try { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(key, credential); var retrieved = await credentialCache.GetObject <Tuple <string, string> >(key); Assert.Equal("somebody", retrieved.Item1); Assert.Equal("somebody's secret", retrieved.Item2); var retrieved2 = await credentialCache.GetObject <Tuple <string, string> >("git:" + key + "/"); Assert.Equal("somebody", retrieved2.Item1); Assert.Equal("somebody's secret", retrieved2.Item2); var retrieved3 = await credentialCache.GetObject <Tuple <string, string> >("login:"******"/"); Assert.Equal("somebody", retrieved3.Item1); Assert.Equal("somebody's secret", retrieved3.Item2); } finally { await credentialCache.Invalidate(key); } } }
public async Task ThrowsObservableInvalidOperationExceptionWhenRetrievingSomethingNotATuple() { using (var credentialCache = new CredentialCache()) { await Assert.ThrowsAsync<InvalidOperationException>( async () => await credentialCache.GetObject<string>("_")); } }
public async Task ThrowsObservableInvalidOperationExceptionWhenRetrievingSomethingNotATuple() { using (var credentialCache = new CredentialCache()) { await Assert.ThrowsAsync <InvalidOperationException>( async() => await credentialCache.GetObject <string>("_")); } }
public async Task ThrowsObjectDisposedExceptionWhenDisposed() { using (var credentialCache = new CredentialCache()) { credentialCache.Dispose(); await Assert.ThrowsAsync<ObjectDisposedException>( async () => await credentialCache.GetObject<Tuple<string, string>>("_")); } }
public async Task ThrowsObjectDisposedExceptionWhenDisposed() { using (var credentialCache = new CredentialCache()) { credentialCache.Dispose(); await Assert.ThrowsAsync <ObjectDisposedException>( async() => await credentialCache.GetObject <Tuple <string, string> >("_")); } }