Пример #1
0
        public async Task CreateAsync_ReturnsCorrectCreatedItem()
        {
            var id          = Guid.Parse("F7148339-E162-4657-B886-C29BF6A2D312");
            var currentTime = new DateTime(2018, 9, 27, 18, 32, 54);

            var(receivedItem, expectedItem) = MockRepository(id, currentTime);
            MockWrappers(id, currentTime);

            var actualItem = await _itemCreatingService.CreateAsync(receivedItem);

            Assert.That(actualItem, Is.EqualTo(expectedItem).UsingItemComparer());
        }
        public async Task <IHttpActionResult> PostItemAsync([FromBody] Item item)
        {
            if (!PostIsItemValid(item))
            {
                return(BadRequest(ModelState));
            }

            var createdItem = await _itemCreatingService.CreateAsync(item);

            var itemUrl = _urlService.GetItemUrl(createdItem.Id);

            return(Created(itemUrl, createdItem));
        }