コード例 #1
0
        public async Task <IActionResult> GetBaskets(string basketId)
        {
            var result = await this.getBasketsById
                         .Execute(GetBasketsByIdRequest.Create(basketId));

            if (null == result)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
コード例 #2
0
        public async Task GetBasketsById_NullBasketId_ThrowsException()
        {
            //Arrange
            string basketId = null;
            var    mock     = GetBasketsByIdMock.Create();
            var    target   = mock.Target;
            var    request  = GetBasketsByIdRequest.Create(basketId);

            //Act
            async Task execute() => await target.Execute(request);

            //Assert
            await Assert.ThrowsAsync <ArgumentException>(execute);
        }
コード例 #3
0
        public async Task GetBasketsById_WithId_ReturnsBasket()
        {
            //Arrange
            var basketId = Guid.NewGuid().ToString();
            var mock     = GetBasketsByIdMock.Create();
            var target   = mock.Target;
            var request  = GetBasketsByIdRequest.Create(basketId);

            //Act
            var actual = await target.Execute(request);

            //Assert
            mock.BasketsRepositoryMock.Verify(rep => rep.Get(basketId), Times.Once());
        }