public static (IStream <T>, string) CreateBlankStream <T>() { var channel = Channel.CreateUnbounded <object?>(); var stream = new FakeStream <T>(channel.Reader.ReadAllAsync().Select(x => FakeConfiguration.Deserialize <T>(x))); var name = $"-{Guid.NewGuid()}"; blankStreams[name] = channel.Writer; return(stream, name); }
public FakeAgent RegisterFunction <TParams>(string functionDelegate, Action <TParams> function) { functions.Add(functionDelegate, (input) => { function(FakeConfiguration.Deserialize <TParams>(input)); return(Task.FromResult <object?>(null)); }); return(this); }
public FakeAgent RegisterFunction <TParams>(string functionDelegate, Func <TParams, Task> function) { functions.Add(functionDelegate, async(input) => { await function(FakeConfiguration.Deserialize <TParams>(input)); return(null); }); return(this); }
public FakeAgent RegisterFunction <TParams, TResult>(string functionDelegate, Func <TParams, TResult> function) { functions.Add(functionDelegate, (input) => Task.FromResult(FakeConfiguration.Serialize(function(FakeConfiguration.Deserialize <TParams>(input))))); return(this); }
public T GetValue <T>(string key, Func <T> defaultValueFactory) { return(FakeConfiguration.Deserialize <T>(Values.GetOrAdd(key, _k => FakeConfiguration.Serialize(defaultValueFactory())))); }
public T GetValue <T>(string key) { return(FakeConfiguration.Deserialize <T>(Values[key])); }