public async Task ThrowsObservableKeyNotFoundExceptionWhenKeyNotFound() { using (var credentialCache = new CredentialCache()) { await Assert.ThrowsAsync <KeyNotFoundException>(async() => await credentialCache.Get("unknownkey")); } }
public async Task ThrowsObjectDisposedExceptionWhenDisposed() { using (var credentialCache = new CredentialCache()) { credentialCache.Dispose(); await Assert.ThrowsAsync <ObjectDisposedException>( async() => await credentialCache.Get("_")); } }
public async Task InvalidatesTheCredential() { using (var credentialCache = new CredentialCache()) { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(nameof(InvalidatesTheCredential), credential); await credentialCache.Invalidate(nameof(InvalidatesTheCredential)); await Assert.ThrowsAsync <KeyNotFoundException>(async() => await credentialCache.Get(nameof(InvalidatesTheCredential))); } }
public async Task InvalidatesTheCredential() { const string key = "TheInvalidateObjectMethod.InvalidatesTheCredential"; using (var credentialCache = new CredentialCache()) { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(key, credential); await credentialCache.InvalidateObject <Tuple <string, string> >(key); await Assert.ThrowsAsync <KeyNotFoundException>(async() => await credentialCache.Get(key)); } }
public async Task InvalidatesTheCredential() { const string key = nameof(InvalidatesTheCredential); using (var credentialCache = new CredentialCache()) { try { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(key, credential); } finally { await credentialCache.InvalidateObject <Tuple <string, string> >(key); await Assert.ThrowsAsync <KeyNotFoundException>(async() => await credentialCache.Get("unknownkey")); } } }
public async Task RetrievesPasswordAsUnicodeBytes() { using (var credentialCache = new CredentialCache()) { try { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(nameof(RetrievesPasswordAsUnicodeBytes), credential); var retrieved = await credentialCache.Get(nameof(RetrievesPasswordAsUnicodeBytes)); Assert.Equal("somebody's secret", Encoding.Unicode.GetString(retrieved)); } finally { await credentialCache.Invalidate(nameof(RetrievesPasswordAsUnicodeBytes)); } } }
public async Task InvalidatesTheCredential() { const string key = nameof(InvalidatesTheCredential); using (var credentialCache = new CredentialCache()) { try { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(key, credential); } finally { await credentialCache.InvalidateObject<Tuple<string, string>>(key); await Assert.ThrowsAsync<KeyNotFoundException>(async () => await credentialCache.Get("unknownkey")); } } }
public async Task InvalidatesTheCredential() { using (var credentialCache = new CredentialCache()) { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(nameof(InvalidatesTheCredential), credential); await credentialCache.Invalidate(nameof(InvalidatesTheCredential)); await Assert.ThrowsAsync<KeyNotFoundException>(async () => await credentialCache.Get(nameof(InvalidatesTheCredential))); } }
public async Task ThrowsObjectDisposedExceptionWhenDisposed() { using (var credentialCache = new CredentialCache()) { credentialCache.Dispose(); await Assert.ThrowsAsync<ObjectDisposedException>( async () => await credentialCache.Get("_")); } }
public async Task ThrowsObservableKeyNotFoundExceptionWhenKeyNotFound() { using (var credentialCache = new CredentialCache()) { await Assert.ThrowsAsync<KeyNotFoundException>(async () => await credentialCache.Get("unknownkey")); } }
public async Task InvalidatesTheCredential() { const string key = "TheInvalidateObjectMethod.InvalidatesTheCredential"; using (var credentialCache = new CredentialCache()) { var credential = Tuple.Create("somebody", "somebody's secret"); await credentialCache.InsertObject(key, credential); await credentialCache.InvalidateObject<Tuple<string, string>>(key); await Assert.ThrowsAsync<KeyNotFoundException>(async () => await credentialCache.Get(key)); } }