Example #1
0
            public void When_InstantiatingResponseWithItem_Expect_ResponseWithItem()
            {
                // Arrange
                Item item = new Item();

                // Act
                AddItem.Response response = new AddItem.Response(item);

                // Assert
                Assert.Equal(item, response.Item);
            }
        public async Task <ActionResult> AddItem(int bucketId, [FromBody] Item item)
        {
            AddItem.Command command = new AddItem.Command(
                bucketId: bucketId,
                name: item.Name,
                description: item.Description);

            AddItem.Response response = await this.mediator.Send(command);

            item = this.mapper.Map <Item>(response.Item);

            return(this.CreatedAtRoute("GetItem", new { bucketId, itemId = item.Id }, item));
        }
Example #3
0
            public async Task When_AddingItemToBucket_Expect_AddedItem()
            {
                // Arrange
                Bucket bucket = new Bucket();

                await this.repository.AddAsync(bucket);

                AddItem.Command command = new AddItem.Command(
                    bucketId: bucket.Id,
                    name: Guid.NewGuid().ToString(),
                    description: null);

                AddItem.Handler handler = new AddItem.Handler(this.repository);

                // Act
                AddItem.Response response = await handler.Handle(command, default);

                // Assert
                Assert.NotEqual(default, response.Item.Id);