示例#1
0
        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);
        }
示例#2
0
 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);
 }
示例#3
0
 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);
 }
示例#4
0
 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);
 }
示例#5
0
 public T GetValue <T>(string key, Func <T> defaultValueFactory)
 {
     return(FakeConfiguration.Deserialize <T>(Values.GetOrAdd(key, _k => FakeConfiguration.Serialize(defaultValueFactory()))));
 }
示例#6
0
 public T GetValue <T>(string key)
 {
     return(FakeConfiguration.Deserialize <T>(Values[key]));
 }