public async Task ClientStore_SaveGetByClientIdTest() { Stopwatch stopwatch = new Stopwatch(); var storageContext = Services.BuildServiceProvider().GetService <ClientStorageContext>(); Assert.IsNotNull(storageContext); var store = new ClientStore(storageContext, _logger); Assert.IsNotNull(store); var client = CreateTestObject(); Console.WriteLine(JsonConvert.SerializeObject(client)); stopwatch.Start(); await store.StoreAsync(client); stopwatch.Stop(); Console.WriteLine($"ClientStore.StoreAsync({client.ClientId}): {stopwatch.ElapsedMilliseconds} ms"); stopwatch.Reset(); stopwatch.Start(); var findClient = await store.FindClientByIdAsync(client.ClientId); stopwatch.Stop(); Console.WriteLine($"ClientStore.FindClientByIdAsync({client.ClientId}): {stopwatch.ElapsedMilliseconds} ms"); Assert.AreEqual <string>(client.ClientId, findClient.ClientId); stopwatch.Reset(); stopwatch.Start(); var clients = await store.GetAllClients(); int count = clients.Count(); stopwatch.Stop(); Console.WriteLine($"ClientStore.GetAllClients() Count: {count} : {stopwatch.ElapsedMilliseconds} ms"); Assert.IsTrue(count > 0); stopwatch.Reset(); stopwatch.Start(); var getClient = (await store.GetAllClients()).FirstOrDefault(f => f.ClientId == client.ClientId); stopwatch.Stop(); Console.WriteLine($"ClientStore.GetAllClients(): {stopwatch.ElapsedMilliseconds} ms"); Assert.IsNotNull(getClient); }
public async Task ClientStore_RemoveByClientIdTest() { var storageContext = Services.BuildServiceProvider().GetService <ClientStorageContext>(); Assert.IsNotNull(storageContext); var store = new ClientStore(storageContext, _logger); Assert.IsNotNull(store); var client = CreateTestObject(); client.ClientId = Guid.NewGuid().ToString(); Console.WriteLine(JsonConvert.SerializeObject(client)); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); await store.StoreAsync(client); stopwatch.Stop(); Console.WriteLine($"ClientStore.StoreAsync({client.ClientId}): {stopwatch.ElapsedMilliseconds} ms"); stopwatch.Reset(); stopwatch.Start(); await store.RemoveAsync(client.ClientId); stopwatch.Stop(); Console.WriteLine($"ClientStore.RemoveAsync({client.ClientId}): {stopwatch.ElapsedMilliseconds} ms"); stopwatch.Reset(); stopwatch.Start(); var findClient = await store.FindClientByIdAsync(client.ClientId); stopwatch.Stop(); Console.WriteLine($"ClientStore.FindClientByIdAsync({client.ClientId}): {stopwatch.ElapsedMilliseconds} ms"); Assert.IsNull(findClient); stopwatch.Reset(); stopwatch.Start(); var getClient = (await store.GetAllClients()).FirstOrDefault(f => f.ClientId == client.ClientId); stopwatch.Stop(); Console.WriteLine($"ClientStore.GetAllClients(): {stopwatch.ElapsedMilliseconds} ms"); Assert.IsNull(getClient); }