Esempio n. 1
0
        public void Handle_NoShipMethodsExists_ThrowException(
            [Frozen] Mock <IRepository <Entities.ShipMethod> > shipMethodRepoMock,
            GetShipMethodsQueryHandler sut,
            GetShipMethodsQuery query
            )
        {
            //Arrange
            shipMethodRepoMock.Setup(x => x.ListAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync((List <Entities.ShipMethod>)null);

            //Act
            Func <Task> func = async() => await sut.Handle(query, CancellationToken.None);

            //Assert
            func.Should().ThrowAsync <ArgumentNullException>();
            shipMethodRepoMock.Verify(x => x.ListAsync(It.IsAny <CancellationToken>()));
        }
Esempio n. 2
0
        public async Task Handle_ShipMethodsExists_ReturnShipMethods(
            List <Entities.ShipMethod> shipMethods,
            [Frozen] Mock <IRepository <Entities.ShipMethod> > shipMethodRepoMock,
            GetShipMethodsQueryHandler sut,
            GetShipMethodsQuery query
            )
        {
            //Arrange
            shipMethodRepoMock.Setup(x => x.ListAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(shipMethods);

            //Act
            var result = await sut.Handle(query, CancellationToken.None);

            //Assert
            result.Should().NotBeNull();
            shipMethodRepoMock.Verify(x => x.ListAsync(It.IsAny <CancellationToken>()));

            for (int i = 0; i < result.Count; i++)
            {
                result[i].Name.Should().Be(shipMethods[i].Name);
            }
        }