public void CreatesCommand()
        {
            var commandDto = BuildCreatePurchaseApplicationCommandDto();

            var result = CreatePurchaseApplicationCommand.Create(commandDto);

            result.IsSuccess.Should().BeTrue();
            result.IfSuccess(command =>
            {
                command.Products.Count.Should().Be(commandDto.Products.Count);
                var expectedLink = Link.Create(commandDto.Products.First().Link.ValueUnsafe()).IfFail(() => null);
                command.Products.First().Link.Should().Be(expectedLink);
                var expectedUnits = Units.Create(commandDto.Products.First().Units).IfFail(() => null);
                command.Products.First().Units.Should().Be(expectedUnits);
                var expectedAdditionalInformation = AdditionalInformation.Create(commandDto.Products.First().AdditionalInformation).IfFail(() => null);
                command.Products.First().AdditionalInformation.IsSome.Should().BeTrue();
                command.Products.First().AdditionalInformation.IfSome(x => x.Should().Be(expectedAdditionalInformation));
                var expectedPromotionCode = PromotionCode.Create(commandDto.Products.First().PromotionCode).IfFail(() => null);
                command.Products.First().PromotionCode.IsSome.Should().BeTrue();
                command.Products.First().PromotionCode.IfSome(x => x.Should().Be(expectedPromotionCode));
                var expectedClientName = Name.Create(commandDto.Client.Email).IfFail(() => null);
                command.ClientProp.Name.Should().Be(expectedClientName);
                var expectedClientPhoneNumber = PhoneNumber.Create(commandDto.Client.PhoneNumber).IfFail(() => null);
                command.ClientProp.PhoneNumber.Should().Be(expectedClientPhoneNumber);
                var expectedClientEmail = Email.Create(commandDto.Client.Email).IfFail(() => null);
                command.ClientProp.Email.Should().Be(expectedClientEmail);
                var expectedPurchaseApplicationAdditionalInformation = AdditionalInformation.Create(commandDto.AdditionalInformation).IfFail(() => null);
                command.AdditionalInformation.IsSome.Should().BeTrue();
                command.AdditionalInformation.IfSome(x => x.Should().Be(expectedPurchaseApplicationAdditionalInformation));
            });
        }
Ejemplo n.º 2
0
        public void CreatesProductList()
        {
            var productDto = buildProductDto();

            var result = Product.Create(new List <Product.Dto> {
                productDto
            }.AsReadOnly());

            result.IsSuccess.Should().BeTrue();
            result.IfSuccess(products =>
            {
                products.Count.Should().Be(1);
                var expectedLink = Link.Create(productDto.Link).IfFail(() => null);
                products.First().Link.Should().Be(expectedLink);
                var expectedUnits = Units.Create(productDto.Units).IfFail(() => null);
                products.First().Units.Should().Be(expectedUnits);
                products.First().AdditionalInformation.IsSome.Should().BeTrue();
                var expectedAdditionalInformation = AdditionalInformation.Create(productDto.AdditionalInformation).IfFail(() => null);
                products.First().AdditionalInformation.IfSome(x => x.Should().Be(expectedAdditionalInformation));
                var expectedPromotionCode = PromotionCode.Create(productDto.PromotionCode).IfFail(() => null);
                products.First().PromotionCode.IsSome.Should().BeTrue();
                products.First().PromotionCode.IfSome(x => x.Should().Be(expectedPromotionCode));
            });
        }
Ejemplo n.º 3
0
        public void CreatesPromotionCode()
        {
            var result = PromotionCode.Create("ADDIDAS-123");

            result.IsSuccess.Should().BeTrue();
        }
        public void CreatesPurchaseApplication()
        {
            var request = BuildPurchaseApplicationRequest();

            createPurchaseApplicationCommandHandler
            .Setup(x => x.Create(It.IsAny <CreatePurchaseApplicationCommand>()))
            .Returns(() => PurchaseApplicationBuilder.Build());

            var response = controller.Create(request) as StatusCodeResult;

            response.StatusCode.Should().Be(StatusCodes.Status200OK);
            createPurchaseApplicationCommandHandler
            .Verify(x => x.Create(It.Is <CreatePurchaseApplicationCommand>(y =>
                                                                           y.Products.Count == request.Products.Count &&
                                                                           y.Products.First().Link == Link.Create(request.Products.First().Link).IfFail(() => null) &&
                                                                           y.Products.First().Units == Units.Create(request.Products.First().Units).IfFail(() => null) &&
                                                                           y.Products.First().AdditionalInformation == AdditionalInformation.Create(request.Products.First().AdditionalInformation).IfFail(() => null) &&
                                                                           y.Products.First().PromotionCode == PromotionCode.Create(request.Products.First().PromotionCode).IfFail(() => null) &&
                                                                           y.ClientProp.Email == Email.Create(request.Client.Email).IfFail(() => null) &&
                                                                           y.ClientProp.PhoneNumber == PhoneNumber.Create(request.Client.PhoneNumber).IfFail(() => null) &&
                                                                           y.ClientProp.Name == Name.Create(request.Client.Name).IfFail(() => null) &&
                                                                           y.AdditionalInformation == AdditionalInformation.Create(request.AdditionalInformation).IfFail(() => null))),
                    Times.Once);
        }