Esempio n. 1
0
        public async Task <ActionResult <CategoryResponse> > Create([FromBody] CategoryCreateRequest request)
        {
            var createCategoryModel = _categoryConverter.ToModel(request);
            var category            = await _categoryService.Create(createCategoryModel);

            var response = _categoryConverter.ToResponse(category);

            return(CreatedAtAction(nameof(Read), new { id = response.Id }, response));
        }
Esempio n. 2
0
        public async Task Test_controller_creates_category()
        {
            var request        = new CategoryCreateRequest();
            var model          = new CategoryModel();
            var expectedResult = new CategoryModel();

            A.CallTo(() => _categoryConverter.ToModel(request)).Returns(model);
            A.CallTo(() => _categoryService.Create(model)).Returns(expectedResult);

            var result = await _categoryController.Create(request);
        }