Exemplo n.º 1
0
        public void MapToContract_MapDetails_CallsMapper()
        {
            var salesInvoiceDetail1 = new SalesInvoiceDetail()
            {
            };
            var salesInvoiceDetail2 = new SalesInvoiceDetail()
            {
            };
            var salesInvoice = new SalesInvoiceGet()
            {
                state   = "draft",
                details = new List <SalesInvoiceDetail>()
                {
                    salesInvoiceDetail1,
                    salesInvoiceDetail2
                }
            };

            var mappedDetail1 = new Contract.Model.SalesInvoiceDetail();
            var mappedDetail2 = new Contract.Model.SalesInvoiceDetail();

            _salesInvoiceDetailMapper.Setup(c => c.MapToContract(salesInvoiceDetail1)).Returns(mappedDetail1);
            _salesInvoiceDetailMapper.Setup(c => c.MapToContract(salesInvoiceDetail2)).Returns(mappedDetail2);

            var result = _mapper.MapToContract(salesInvoice);

            result.Details.Should().Contain(mappedDetail1);
            result.Details.Should().Contain(mappedDetail2);
            _salesInvoiceDetailMapper.VerifyAll();
        }
Exemplo n.º 2
0
        public void MapToApi_MapSalesInvoiceDetails_CallsMapper()
        {
            var current             = new SalesInvoiceGet();
            var salesInvoiceDetail1 = new Contract.Model.SalesInvoiceDetail()
            {
            };
            var salesInvoiceDetail2 = new Contract.Model.SalesInvoiceDetail()
            {
            };
            var salesInvoice = new Contract.Model.SalesInvoice()
            {
                State   = Contract.Model.SalesInvoiceStatus.Draft,
                Details = new List <Contract.Model.SalesInvoiceDetail>()
                {
                    salesInvoiceDetail1,
                    salesInvoiceDetail2
                }
            };

            var salesInvoiceDetail = new SalesInvoiceDetail();
            var salesInvoiceDetai2 = new SalesInvoiceDetail();

            _salesInvoiceDetailMapper.Setup(c => c.MapToApi(salesInvoiceDetail1, null)).Returns(salesInvoiceDetail);
            _salesInvoiceDetailMapper.Setup(c => c.MapToApi(salesInvoiceDetail2, null)).Returns(salesInvoiceDetai2);

            var result = _mapper.MapToApi(salesInvoice, current);

            result.details_attributes.Should().Contain(salesInvoiceDetail);
            result.details_attributes.Should().Contain(salesInvoiceDetai2);
            _salesInvoiceDetailMapper.VerifyAll();
        }