Ejemplo n.º 1
0
        public async Task InsertBasketItem_NullRequest_ThrowsException()
        {
            //Arrange
            var mock   = InsertBasketItemMock.Create();
            var target = mock.Target;
            InsertBasketItemRequest request = null;

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

            //Assert
            await Assert.ThrowsAsync <ArgumentNullException>(execute);
        }
Ejemplo n.º 2
0
        public async Task InsertBasketItem_NullVariant_ThrowsException()
        {
            //Arrange
            var    fixture     = new Fixture();
            var    basketId    = fixture.Create <string>();
            string itemVariant = null;
            var    quantity    = fixture.Create <int>();
            var    mock        = InsertBasketItemMock.Create();
            var    target      = mock.Target;
            var    request     = InsertBasketItemRequest.Create(basketId, itemVariant, quantity);

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

            //Assert
            await Assert.ThrowsAsync <ArgumentException>(execute);
        }
Ejemplo n.º 3
0
        public async Task InsertBasketItem_ValidRequest_ProducerCalledOnce()
        {
            //Arrange
            var fixture     = new Fixture();
            var basketId    = fixture.Create <string>();
            var itemVariant = fixture.Create <string>();
            var quantity    = fixture.Create <int>();
            var mock        = InsertBasketItemMock.Create();
            var target      = mock.Target;
            var request     = InsertBasketItemRequest.Create(basketId, itemVariant, quantity);

            //Act
            await target.Execute(request);

            //Assert
            mock.BasketUpdatedProducerMock.Verify(x => x.ProduceBasketUpdatedEventAsync(It.IsAny <string>()), Times.Once());
        }
Ejemplo n.º 4
0
        public async Task InsertBasketItem_ValidRequest_RepositoryCalledOnce()
        {
            //Arrange
            var fixture     = new Fixture();
            var basketId    = fixture.Create <string>();
            var itemVariant = fixture.Create <string>();
            var quantity    = 2;
            var mock        = InsertBasketItemMock.Create();
            var target      = mock.Target;
            var request     = InsertBasketItemRequest.Create(basketId, itemVariant, quantity);

            //Act
            await target.Execute(request);

            //Assert
            mock.BasketsRepositoryMock.Verify(rep => rep.InsertItem(basketId, It.IsAny <Item>()), Times.Once());
        }