public void CanPutKeyTwice() { LocalKeyValueStore store = new LocalKeyValueStore(); TestUtils.SinglePutGet(store, "key1", "value1"); TestUtils.SinglePutGet(store, "key1", "value2"); }
public void CannotPutEmptyStringKey() { LocalKeyValueStore store = new LocalKeyValueStore(); Assert.Throws <ArgumentException>(() => { TestUtils.SinglePutGet(store, string.Empty, "value"); }); }
public void CanPutEmptyString() { LocalKeyValueStore store = new LocalKeyValueStore(); TestUtils.SinglePutGet(store, "key1", string.Empty); Assert.Throws <ArgumentNullException>(() => { TestUtils.SinglePutGet(store, "key1", null); }); }
public void CanPutAndRetrieve() { LocalKeyValueStore store = new LocalKeyValueStore(); TestUtils.SinglePutGet(store, "key1", "value1"); TestUtils.SinglePutGet(store, "key2", "value2"); // Keys are case-sensitive: string notFound = string.Empty; TestUtils.AssertGet(store, "KEY1", notFound); }
public void CanDeleteKey() { LocalKeyValueStore store = new LocalKeyValueStore(); const string key = "key_to_be_deleted"; TestUtils.SinglePutGet(store, key, "value"); store.Delete(key); TestUtils.AssertGet(store, key, string.Empty); // Delete non-existent key: store.Delete(key); TestUtils.AssertGet(store, key, string.Empty); }
private async Task <ServiceRegistry> CreateServiceRegistryAsync() { Stopwatch watch = Stopwatch.StartNew(); IKeyValueStore keyValueStore = await TryGetEtcdKeyValueStore(); List <AgentConfiguration> serviceAgents = new List <AgentConfiguration>(); if (keyValueStore != null) { _logger.LogInformation("Connected to distributed key-value store in {millis}ms", watch.ElapsedMilliseconds); } else { _logger.LogWarning( "Unable to connect to distributed key-value store. Using Worker agents from configuration:"); keyValueStore = new LocalKeyValueStore(); _keyValueStoreIsLocal = true; serviceAgents.AddRange(KnownAgents.Get(WellKnownAgentType.Worker)); } ServiceRegistry serviceRegistry = new ServiceRegistry(keyValueStore, string.Empty); AddServices(serviceRegistry, serviceAgents); int endpointCount = serviceRegistry.GetTotalEndpointCount(out var serviceCount); _logger.LogInformation( "Service registry contains {serviceCount} service type(s) at {endpointCount} " + "different endpoints.", serviceCount, endpointCount); return(serviceRegistry); }
public void CanGetNonExistingKey() { LocalKeyValueStore store = new LocalKeyValueStore(); TestUtils.AssertGet(store, "noes not exist", string.Empty); }
public void CanGetRange() { LocalKeyValueStore store = new LocalKeyValueStore(); TestUtils.AssertCanGetRange(store); }