public async Task Test1() { #if (!MakeSdk) //Write test code here await Task.CompletedTask; #else //This is an example for testing genereated clients FooClient client = new FooClient("") { CreateHttpClient = _server.CreateClient, Authorization = "Admin-Administrator" }; var args = new FooArgs() { DisplayName = "Foo", IsBar = true, Value = 25 }; var id = await client.PostAsync(args); var result = await client.GetByIdAsync(id); Assert.Equal(args.DisplayName, result.DisplayName); Assert.Equal(args.IsBar, result.IsBar); Assert.Equal(args.Value, result.Value); #endif }
public async Task <IActionResult> PostAsync([FromBody] FooArgs args) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = _entityIndex.NextId(ResourceTypes.Foo); await EntityManager.CreateEntityAsync(_eventStore, args, ResourceTypes.Foo, id, User.Identity.GetUserIdentity()); return(Created($"{Request.Scheme}://{Request.Host}/api/Foo/{id}", id)); }
public void ShouldAssertRaiseAndReturnForFuncCallWithOneArg() { var executor = Mock.Create <IExecutor <int> >(); Mock.Arrange(() => executor.Echo(Arg.IsAny <string>())) .Raises(() => executor.Done += null, (string s) => new FooArgs { Value = s }) .Returns((string s) => s); FooArgs args = null; executor.Done += (sender, e) => args = e; Assert.Equal(executor.Echo("echo"), args.Value); }
public void ShouldRaiseEventForEventArgsLambdaWithFourArguments() { var executor = Mock.Create <IExecutor <int> >(); Mock.Arrange(() => executor.Execute(Arg.IsAny <string>(), Arg.IsAny <int>(), Arg.IsAny <bool>(), Arg.IsAny <string>())) .Raises(() => executor.Done += null, (string s, int i, bool b, string s1) => new FooArgs { Value = s + i + b + s1 }); FooArgs args = null; executor.Done += (sender, e) => args = e; executor.Execute("done", 4, true, "ok"); Assert.Equal(args.Value, "done4Trueok"); }
public void ShouldRaiseEventForEventArgsLambdaWithTwoArguments() { var executor = Mock.Create <IExecutor <int> >(); Mock.Arrange(() => executor.Execute(Arg.IsAny <string>(), Arg.IsAny <int>())) .Raises(() => executor.Done += null, (string s, int i) => new FooArgs { Value = s + i }); FooArgs args = null; executor.Done += (sender, e) => args = e; executor.Execute("done", 2); Assert.Equal(args.Value, "done2"); }
public async Task <IActionResult> PutAsync(int id, [FromBody] FooArgs args) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_entityIndex.Exists(ResourceTypes.Foo, id)) { return(NotFound()); } var oldFoo = await _eventStore.EventStream.GetCurrentEntityAsync <FooArgs>(ResourceTypes.Foo, id); await EntityManager.UpdateEntityAsync(_eventStore, oldFoo, args, ResourceTypes.Foo, id, User.Identity.GetUserIdentity()); return(NoContent()); }
public void ShouldNotCallDelegateAfterEventDetach() { var executor = Mock.Create <IExecutor <int> >(); Mock.Arrange(() => executor.Execute(Arg.IsAny <string>())) .Raises(() => executor.Done += null, (string s) => new FooArgs { Value = s }); FooArgs args = null; EventHandler <FooArgs> handler = (sender, e) => args = e; executor.Done += (o, e) => { }; executor.Done += handler; executor.Execute("done"); Assert.Equal(args.Value, "done"); executor.Done -= handler; args = null; executor.Execute("done"); Assert.Null(args); }
public void FooNoResult(FooArgs args) { this.Args = args; }
public FooResult Foo(FooArgs args) { this.Args = args; return Result; }
public Foo(FooArgs args) { DisplayName = args.DisplayName; IsBar = args.IsBar; Value = args.Value; }
public FooResult Foo(FooArgs args) { this.Args = args; return(Result); }
// Function public void FooWithMessage(FooArgs arg) => Debug.Log(arg.value);