Skip to content

Instantly share code, notes, and snippets.

@dtchepak
Created January 7, 2014 21:41
Show Gist options
  • Save dtchepak/8307406 to your computer and use it in GitHub Desktop.
Save dtchepak/8307406 to your computer and use it in GitHub Desktop.
public class KVStoreExamples
{
[Fact]
public void GetValueForExistingKey()
{
var kv =
from a in KVStore.add("a", 1)
from b in KVStore.add("b", 2)
from c in KVStore.add("c", 3)
select c
;
var getC = from s in kv
from c in KVStore.get<string, int>("c")
select c;
var result = getC.InterpretWithSideEffects();
Assert.Equal(3, result.ValueOr(() => 0));
}
[Fact]
public void GetValueForNonExistingKey()
{
var kv = KVStore.add("a", 1);
var getC = from s in kv
from c in KVStore.get<string, int>("c")
select c;
var result = getC.InterpretWithSideEffects();
Assert.True(result.IsEmpty);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment