public async Task ExpirationTest() { var keyValue = new MemoryKeyValueProvder(); int timetoLife = 1; await keyValue.SetValue("TestKey01", "nothing else matter", timetoLife, false); await keyValue.SetValue("TestKey02", "nothing else matter", timetoLife + 2, false); Thread.Sleep(TimeSpan.FromSeconds(1)); try { var testValue01 = await keyValue.GetValue("TestKey01"); } catch (SpAccessDeniedOrObjectNotExistsException) { } var testValue02 = (KeyValueItem)await keyValue.GetValue("TestKey02"); Assert.IsTrue(testValue02.KeyName == "TestKey02"); }
public async Task SetValueTest() { var keyValue = new MemoryKeyValueProvder(); int timetoLife = 20; await keyValue.SetValue("TestKey01", "nothing else matter", timetoLife, false); await keyValue.SetValue("TestKey02", "nothing else matter", timetoLife, false); // Check isOverwrite option try { await keyValue.SetValue("TestKey01", "nothing else matter", timetoLife, false); } catch (SpObjectAlreadyExists) { } await keyValue.SetValue("TestKey01", "updated", timetoLife, true); var value = (KeyValueItem)await keyValue.GetValue("TestKey01"); Assert.IsTrue(value.TextValue == "updated"); }
public async Task DeleteTest() { var keyValue = new MemoryKeyValueProvder(); int timetoLife = 20; await keyValue.SetValue("TestKey01", "nothing else matter", timetoLife, false); await keyValue.SetValue("TestKey02", "nothing else matter", timetoLife, false); try { await keyValue.Delete("NotExistKey"); } catch (SpAccessDeniedOrObjectNotExistsException) { } await keyValue.Delete("TestKey01"); try { var value = (KeyValueItem)await keyValue.GetValue("TestKey01"); } catch (SpAccessDeniedOrObjectNotExistsException) { } }