public void CanCreateCategory()
        {
            // ARRANGE
            var newCategoryMessage  = Substitute.For <NewCategoryMessage>();
            var expectedCategoryDto = Substitute.For <CategoryDto>();

            _noteTaker.CreateNewCategory(Arg.Any <SecurityContext>(), newCategoryMessage).Returns(expectedCategoryDto);

            // ACT
            var result = _subjectUnderTest.Post(newCategoryMessage);

            // ASSERT
            Assert.That(result, Is.Not.Null);
            _noteTaker.Received(1).CreateNewCategory(Arg.Any <SecurityContext>(), newCategoryMessage);
        }
Пример #2
0
        public IActionResult Post([FromBody] NewCategoryMessage newCategoryMessage)
        {
            var categoryDto = _noteTaker.CreateNewCategory(SecurityContext, newCategoryMessage);

            return(CreatedAtAction("Get", new { id = categoryDto.Id }, categoryDto));
        }