Exemplo n.º 1
0
        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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 7
0
        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;
 }
Exemplo n.º 10
0
 public Foo(FooArgs args)
 {
     DisplayName = args.DisplayName;
     IsBar       = args.IsBar;
     Value       = args.Value;
 }
 public void FooNoResult(FooArgs args)
 {
     this.Args = args;
 }
 public FooResult Foo(FooArgs args)
 {
     this.Args = args;
     return(Result);
 }
Exemplo n.º 13
0
 // Function
 public void FooWithMessage(FooArgs arg) => Debug.Log(arg.value);