public void SmsPaymentPriceForNomenclatureDistributionsWithoutFraction()
        {
            // arrange
            var organizationProvidertMock = Substitute.For <IOrganizationProvider>();
            var smsPaymentMock            = Substitute.For <SmsPayment>();
            var orderMock       = Substitute.For <Order>();
            var uowMock         = Substitute.For <IUnitOfWork>();
            var paymentFromMock = Substitute.For <PaymentFrom>();

            SmsPaymentDTOFactory smsPaymentDTOFactory = new SmsPaymentDTOFactory(organizationProvidertMock);

            orderMock.OrderItems = new List <OrderItem>
            {
                new OrderItem {
                    Count = 3, Price = 300, Nomenclature = new Nomenclature()
                },
            };

            // act

            var smsPaymentDTO = smsPaymentDTOFactory.CreateSmsPaymentDTO(uowMock, smsPaymentMock, orderMock, paymentFromMock);

            // assert

            Assert.That(smsPaymentDTO.Items.Count, Is.EqualTo(1));

            Assert.That(smsPaymentDTO.Items[0].Price, Is.EqualTo(300));
            Assert.That(smsPaymentDTO.Items[0].Quantity, Is.EqualTo(3));
        }
        public void SmsPaymentPriceForNomenclatureDistributionsWithCirculatingFractionCombine()
        {
            // arrange
            var organizationProvidertMock = Substitute.For <IOrganizationProvider>();
            var smsPaymentMock            = Substitute.For <SmsPayment>();
            var orderMock       = Substitute.For <Order>();
            var uowMock         = Substitute.For <IUnitOfWork>();
            var paymentFromMock = Substitute.For <PaymentFrom>();

            SmsPaymentDTOFactory smsPaymentDTOFactory = new SmsPaymentDTOFactory(organizationProvidertMock);

            orderMock.OrderItems = new List <OrderItem>
            {
                new OrderItem {
                    Count = 3, Price = 150, DiscountMoney = 50, Nomenclature = new Nomenclature()
                },
                new OrderItem {
                    Count = 7, Price = 200, DiscountMoney = 400, Nomenclature = new Nomenclature()
                },
                new OrderItem {
                    Count = 3, Price = 100, Nomenclature = new Nomenclature()
                }
            };

            // act

            var smsPaymentDTO = smsPaymentDTOFactory.CreateSmsPaymentDTO(uowMock, smsPaymentMock, orderMock, paymentFromMock);

            // assert

            Assert.That(smsPaymentDTO.Items.Count, Is.EqualTo(4));

            Assert.That(smsPaymentDTO.Items[0].Price, Is.EqualTo(133.33));
            Assert.That(smsPaymentDTO.Items[0].Quantity, Is.EqualTo(2));

            Assert.That(smsPaymentDTO.Items[1].Price, Is.EqualTo(133.32));
            Assert.That(smsPaymentDTO.Items[1].Quantity, Is.EqualTo(1));

            Assert.That(smsPaymentDTO.Items[2].Price, Is.EqualTo(142.86));
            Assert.That(smsPaymentDTO.Items[2].Quantity, Is.EqualTo(7));

            Assert.That(smsPaymentDTO.Items[3].Price, Is.EqualTo(100));
            Assert.That(smsPaymentDTO.Items[3].Quantity, Is.EqualTo(3));
        }
        public void SmsPaymentItemsPriceSumEqualOrderSum(Order order)
        {
            // arrange
            var organizationProvidertMock = Substitute.For <IOrganizationProvider>();
            var smsPaymentMock            = Substitute.For <SmsPayment>();
            var uowMock         = Substitute.For <IUnitOfWork>();
            var paymentFromMock = Substitute.For <PaymentFrom>();

            SmsPaymentDTOFactory smsPaymentDTOFactory = new SmsPaymentDTOFactory(organizationProvidertMock);

            // act

            var smsPaymentDTO = smsPaymentDTOFactory.CreateSmsPaymentDTO(uowMock, smsPaymentMock, order, paymentFromMock);
            var result        = smsPaymentDTO.Items.Sum(x => x.Price * x.Quantity);

            // assert

            Assert.That(result, Is.EqualTo(order.OrderSum));
        }