Esempio n. 1
0
        public async Task Should_post_application_data()
        {
            var contract = new ApplicationResponseModelContract
            {
                Id      = 1,
                Name    = "App01",
                Version = "0.1"
            };

            var model = new ApplicationModel
            {
                Name    = "App01",
                Version = "0.1"
            };

            _applicationAppService.Add(model).Returns(new ApplicationResponseModel
            {
                Id      = 1,
                Name    = "App01",
                Version = "0.1"
            });

            var result = await _applicationController.Post(model);

            result.Should().NotBeNull();
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var applicationResponseModel = okResult.Value.Should().BeAssignableTo <ApplicationResponseModel>().Subject;

            contract.Should().BeEquivalentTo(applicationResponseModel);
        }
Esempio n. 2
0
        public async Task <IActionResult> Post(ApplicationModel model)
        {
            try
            {
                var app = await _applicationAppService.Add(model);

                return(Response(app));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }