Example #1
0
        public void Init()
        {
            IoCInitializer.Init();

            var taskRepository = IoCContainer.Resolve <ITaskRepository>();
            var taskExecutionItemRepository = IoCContainer.Resolve <ITaskExecutionItemRepository>();

            taskService = new TaskService(taskRepository, taskExecutionItemRepository);

            topic           = "123";
            deal            = new Mock <Deal>();
            contractor      = new Mock <Contractor>();
            productionOrder = new Mock <ProductionOrder>();
            taskType        = new TaskType("Type_1");
            state           = new TaskExecutionState("State_1", TaskExecutionStateType.New, 1);
            taskType.AddState(state);
            taskPriority = new TaskPriority("Priority_1", 1);
            currentDate  = DateTime.Now;

            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            var role = new Role("Администратор");

            role.AddPermissionDistribution(new PermissionDistribution(Permission.Task_Create, PermissionDistributionType.All));
            user.AddRole(role);
        }
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            dealRepository = Mock.Get(IoCContainer.Resolve <IDealRepository>());
            clientContractIndicatorService = Mock.Get(IoCContainer.Resolve <IClientContractIndicatorService>());
            dealIndicatorService           = Mock.Get(IoCContainer.Resolve <IDealIndicatorService>());

            blockingService = new BlockingService(dealRepository.Object, dealIndicatorService.Object, clientContractIndicatorService.Object);

            var employee = new Employee("Иван", "Рюрикович", "Васильевич", new EmployeePost("Царь"), null);

            user = new User(employee, "И.В. Грозный", "ivanvas", "ivanvas", new Team("Тестовая команда", null), null);

            var clientType           = new ClientType("Тестовый тип клиента");
            var region               = new ClientRegion("Дубовка");
            var clientServiceProgram = new ClientServiceProgram("Программа удовлетворения клиента");

            clientOk = new Client("Клиент без блокировки", clientType, ClientLoyalty.Follower, clientServiceProgram, region, 5);
            clientWithManualBlocking = new Client("Клиент с ручной блокировкой", clientType, ClientLoyalty.Follower, clientServiceProgram, region, 5);
            clientWithManualBlocking.Block(user);
            clientWithPaymentDelayBlocking = new Client("Клиент с блокировкой по просрочке платежа", clientType, ClientLoyalty.Follower, clientServiceProgram, region, 5);
            clientWithCreditLimitBlocking  = new Client("Клиент с блокировкой по кредитному лимиту", clientType, ClientLoyalty.Follower, clientServiceProgram, region, 5);

            dealWithPrePayment = new Deal("Сделка с предоплатой", user);
            dealWithPrePayment.AddQuota(new DealQuota("Quota 1 с предоплатой", 7));
            dealWithPostPayment14d20k = new Deal("Сделка с отсрочкой платежа 14 дн 20k", user);
            dealWithPostPayment14d20k.AddQuota(new DealQuota("Quota 2 с отсрочкой платежа 14 дн 20k", 8, 14, 20000.0M));
            dealWithPostPayment7d40k = new Deal("Сделка с отсрочкой платежа 7 дн 40k", user);
            dealWithPostPayment7d40k.AddQuota(new DealQuota("Quota 3 с отсрочкой платежа 7 дн 40k", 8, 7, 40000.0M));
            dealWithPostPayment10d30k = new Deal("Сделка с отсрочкой платежа 10 дн 30k", user);
            dealWithPostPayment10d30k.AddQuota(new DealQuota("Quota 4 с отсрочкой платежа 10 дн 30k", 8, 10, 30000.0M));
        }
Example #3
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     IoCInitializer.Init();
 }
Example #4
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            roleRepository = Mock.Get(IoCContainer.Resolve <IRoleRepository>());

            service = new RoleService_Accessor(roleRepository.Object);
            role    = new Role("Тестовая роль");
        }
Example #5
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var juridicalPerson1   = new JuridicalPerson(juridicalLegalForm)
            {
                Id = 1
            };

            accountOrganization = new AccountOrganization("Тестовая собственная организация", "Тестовая собственная организация", juridicalPerson1)
            {
                Id = 1
            };

            var juridicalPerson2 = new JuridicalPerson(juridicalLegalForm)
            {
                Id = 2
            };

            clientOrganization = new ClientOrganization("Тестовая организация клиента", "Тестовая организация клиента", juridicalPerson2)
            {
                Id = 2
            };

            clientContractRepository = Mock.Get(IoCContainer.Resolve <IClientContractRepository>());
            dealRepository           = Mock.Get(IoCContainer.Resolve <IDealRepository>());

            dealIndicatorService = Mock.Get(IoCContainer.Resolve <IDealIndicatorService>());
            expenditureWaybillIndicatorService = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillIndicatorService>());
            storageService = Mock.Get(IoCContainer.Resolve <IStorageService>());
            clientContractIndicatorService = Mock.Get(IoCContainer.Resolve <IClientContractIndicatorService>());
            taskRepository = Mock.Get(IoCContainer.Resolve <ITaskRepository>());

            dealServiceMock = new Mock <DealService>(dealRepository.Object, clientContractRepository.Object, taskRepository.Object, dealIndicatorService.Object,
                                                     expenditureWaybillIndicatorService.Object, storageService.Object, clientContractIndicatorService.Object);

            dealService = dealServiceMock.Object;

            user = new Mock <User>();
            user.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);

            clientContractIndicatorService.Setup(x => x.CalculateCashPaymentLimitExcessByPaymentsFromClient(It.IsAny <ClientContract>())).Returns(0);
        }
        public void Init()
        {
            IoCInitializer.Init();

            taskExecutionItemRepository = IoCContainer.Resolve <ITaskExecutionItemRepository>();
            taskExecutionItemService    = new TaskExecutionItemService(taskExecutionItemRepository);

            currentDate = DateTime.Now;
            user        = new Mock <User>();
            user.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);

            taskType = new Mock <TaskType>();
            taskType.Setup(x => x.States).Returns(new List <TaskExecutionState>()
            {
                taskExecutionState
            });

            task = new Mock <Task>();
            task.Setup(x => x.Type).Returns(taskType.Object);
        }
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            setting = new Setting()
            {
                UseReadyToAcceptStateForReturnFromClientWaybill = false
            };
            settingRepository = Mock.Get(IoCContainer.Resolve <ISettingRepository>());
            settingRepository.Setup(x => x.Get()).Returns(setting);

            storage = new Storage("qwe", StorageType.ExtraStorage)
            {
                Id = 42
            };
            accOrgSender = new Mock <AccountOrganization>();
            accOrgSender.Setup(x => x.Id).Returns(1);
            accOrgRecipient = new Mock <AccountOrganization>();
            accOrgRecipient.Setup(x => x.Id).Returns(2);

            valueAddedTax = new ValueAddedTax();
            user          = new Mock <User>();
            user.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);
            createdBy = new Mock <User>();
            createdBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);
            acceptedBy = new Mock <User>();
            acceptedBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);
            receiptedBy = new Mock <User>();
            receiptedBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);

            var articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа");
            var measureUnit  = new MeasureUnit("шт.", "Штука", "123", 0)
            {
                Id = 1
            };

            articleA = new Article("Тестовый товар A", articleGroup, measureUnit, true)
            {
                Id = 1
            };
            articleB = new Article("Тестовый товар Б", articleGroup, measureUnit, true)
            {
                Id = 2
            };

            receiptWaybillRow1 = new Mock <ReceiptWaybillRow>();
            receiptWaybillRow1.Setup(x => x.Article).Returns(articleA);

            receiptWaybillRow2 = new Mock <ReceiptWaybillRow>();
            receiptWaybillRow2.Setup(x => x.Article).Returns(articleB);


            articleAccountingPrice = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(articleA, 100)
            };

            returnFromClientWaybillRepository = Mock.Get(IoCContainer.Resolve <IReturnFromClientWaybillRepository>());

            articlePriceService = Mock.Get(IoCContainer.Resolve <IArticlePriceService>());
            articlePriceService.Setup(x => x.GetArticleAccountingPrices(It.Is <short>(y => y == storage.Id), It.IsAny <IEnumerable <int> >())).Returns(articleAccountingPrice);
            articlePriceService.Setup(x => x.GetArticleAccountingPrices(It.Is <short>(y => y == storage.Id), It.IsAny <ISubQuery>(), It.IsAny <DateTime>())).Returns(articleAccountingPrice);
            returnFromClientWaybillRepository = Mock.Get(IoCContainer.Resolve <IReturnFromClientWaybillRepository>());

            expenditureWaybillIndicatorService = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillIndicatorService>());
            articleAvailabilityService         = Mock.Get(IoCContainer.Resolve <IArticleAvailabilityService>());

            returnFromClientWaybillService = new ReturnFromClientWaybillService(
                IoCContainer.Resolve <ISettingRepository>(),
                returnFromClientWaybillRepository.Object,
                IoCContainer.Resolve <ITeamRepository>(),
                IoCContainer.Resolve <IDealRepository>(),
                IoCContainer.Resolve <IStorageRepository>(),
                IoCContainer.Resolve <IUserRepository>(),
                IoCContainer.Resolve <IArticlePriceService>(),
                IoCContainer.Resolve <IAcceptedSaleIndicatorService>(),
                IoCContainer.Resolve <IReturnFromClientService>(),
                IoCContainer.Resolve <IFactualFinancialArticleMovementService>(),
                IoCContainer.Resolve <IArticleMovementOperationCountService>(),
                IoCContainer.Resolve <IArticleMovementService>(),
                IoCContainer.Resolve <IDealPaymentDocumentDistributionService>(),
                IoCContainer.Resolve <IDealIndicatorService>(),
                IoCContainer.Resolve <IArticleRevaluationService>(),
                expenditureWaybillIndicatorService.Object,
                articleAvailabilityService.Object
                );

            deal  = new Mock <Deal>();
            quota = new DealQuota("asd", 10, 45, 15000);
            team  = new Team("Тестовая команда", It.IsAny <User>())
            {
                Id = 1
            };

            contract = new Mock <ClientContract>();
            var economicAgent = new Mock <EconomicAgent>();

            accountOrganization = new AccountOrganization("asd", "asd", economicAgent.Object);

            deal.Setup(x => x.IsActive).Returns(true);
            deal.Setup(x => x.IsClosed).Returns(false);
            deal.Setup(x => x.Quotas).Returns(new List <DealQuota> {
                quota
            });
            deal.Setup(x => x.Contract).Returns(contract.Object);
            accountOrganization.AddStorage(storage);

            contract.Setup(x => x.AccountOrganization).Returns(accountOrganization);

            returnFromClientWaybill = new ReturnFromClientWaybill("123", DateTime.Now, accountOrganization, deal.Object, team, storage, new ReturnFromClientReason(), user.Object, createdBy.Object, DateTime.Now);

            sale = new Mock <ExpenditureWaybill>();
            sale.Setup(x => x.Sender).Returns(accountOrganization);
            sale.Setup(x => x.Team).Returns(team);
            sale.Setup(x => x.Is <ExpenditureWaybill>()).Returns(true);
            sale.Setup(x => x.As <ExpenditureWaybill>()).Returns(sale.Object);

            #region Создание позиции 1

            saleRow1 = new Mock <ExpenditureWaybillRow>();
            saleRow1.Setup(x => x.ExpenditureWaybill).Returns(sale.Object);
            saleRow1.Setup(x => x.SaleWaybill).Returns(sale.Object);
            saleRow1.Setup(x => x.Id).Returns(Guid.NewGuid());
            saleRow1.Setup(x => x.SellingCount).Returns(100);
            saleRow1.Setup(x => x.As <ExpenditureWaybillRow>()).Returns(saleRow1.Object);
            saleRow1.Setup(x => x.Is <ExpenditureWaybillRow>()).Returns(true);
            saleRow1.Setup(x => x.Article).Returns(articleA);
            saleRow1.Setup(x => x.SalePrice).Returns(128);
            saleRow1.Setup(x => x.ReceiptWaybillRow).Returns(receiptWaybillRow1.Object);

            #endregion

            #region Создание позиции 2

            saleRow2 = new Mock <ExpenditureWaybillRow>();
            saleRow2.Setup(x => x.ExpenditureWaybill).Returns(sale.Object);
            saleRow2.Setup(x => x.SaleWaybill).Returns(sale.Object);
            saleRow2.Setup(x => x.Id).Returns(Guid.NewGuid());
            saleRow2.Setup(x => x.SellingCount).Returns(100);
            saleRow2.Setup(x => x.As <ExpenditureWaybillRow>()).Returns(saleRow2.Object);
            saleRow2.Setup(x => x.Is <ExpenditureWaybillRow>()).Returns(true);
            saleRow2.Setup(x => x.Article).Returns(articleA);
            saleRow2.Setup(x => x.SalePrice).Returns(128);
            saleRow2.Setup(x => x.ReceiptWaybillRow).Returns(receiptWaybillRow2.Object);

            #endregion

            ReturnFromClientWaybillRow row = new ReturnFromClientWaybillRow(saleRow1.Object, 1);
            returnFromClientWaybill.AddRow(row);

            articleMovementService = new Mock <IArticleMovementService>();

            articleMovementService.Setup(x => x.CancelArticleAcceptance(It.IsAny <WriteoffWaybill>()))
            .Returns(new List <OutgoingWaybillRowSourceReservationInfo>()
            {
                new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1)
            });
            articleMovementService.Setup(x => x.AcceptArticles(It.IsAny <WriteoffWaybill>()))
            .Returns(new List <OutgoingWaybillRowSourceReservationInfo>()
            {
                new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1)
            });
        }
Example #8
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            setting = new Setting()
            {
                UseReadyToAcceptStateForWriteOffWaybill = false
            };
            settingRepository = Mock.Get(IoCContainer.Resolve <ISettingRepository>());
            settingRepository.Setup(x => x.Get()).Returns(setting);

            storage = new Storage("qwe", StorageType.ExtraStorage)
            {
                Id = 42
            };
            accOrgSender = new Mock <AccountOrganization>();
            accOrgSender.Setup(x => x.Id).Returns(1);
            accOrgRecipient = new Mock <AccountOrganization>();
            accOrgRecipient.Setup(x => x.Id).Returns(2);

            valueAddedTax = new ValueAddedTax();
            user          = new Mock <User>();
            user.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);
            createdBy = new Mock <User>();
            createdBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);
            acceptedBy = new Mock <User>();
            acceptedBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);

            var articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа");
            var measureUnit  = new MeasureUnit("шт.", "Штука", "123", 0)
            {
                Id = 1
            };

            articleA = new Article("Тестовый товар A", articleGroup, measureUnit, true)
            {
                Id = 1
            };

            receiptWaybillRow = new Mock <ReceiptWaybillRow>();
            receiptWaybillRow.Setup(x => x.Article).Returns(articleA);

            articleAccountingPrice = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(articleA, 100)
            };

            writeoffWaybillRepository = Mock.Get(IoCContainer.Resolve <IWriteoffWaybillRepository>());
            articleRepository         = Mock.Get(IoCContainer.Resolve <IArticleRepository>());
            articlePriceService       = Mock.Get(IoCContainer.Resolve <IArticlePriceService>());
            articlePriceService.Setup(x => x.GetArticleAccountingPrices(It.Is <short>(y => y == storage.Id), It.IsAny <IEnumerable <int> >())).Returns(articleAccountingPrice);
            articlePriceService.Setup(x => x.GetArticleAccountingPrices(It.Is <short>(y => y == storage.Id), It.IsAny <ISubQuery>(), It.IsAny <DateTime>())).Returns(articleAccountingPrice);

            articleAvailabilityService = Mock.Get(IoCContainer.Resolve <IArticleAvailabilityService>());

            articleMovementService = Mock.Get(IoCContainer.Resolve <IArticleMovementService>());

            receiptWaybillService = Mock.Get(IoCContainer.Resolve <IReceiptWaybillService>());

            articleRevaluationService = Mock.Get(IoCContainer.Resolve <IArticleRevaluationService>());

            factualFinancialArticleMovementService = new Mock <IFactualFinancialArticleMovementService>();

            articleMovementOperationCountService = new Mock <IArticleMovementOperationCountService>();

            storageRepository = Mock.Get(IoCContainer.Resolve <IStorageRepository>());

            userRepository = Mock.Get(IoCContainer.Resolve <IUserRepository>());

            writeoffWaybillService = new WriteoffWaybillService(settingRepository.Object, writeoffWaybillRepository.Object,
                                                                storageRepository.Object, userRepository.Object,
                                                                articleMovementService.Object,
                                                                articlePriceService.Object,
                                                                factualFinancialArticleMovementService.Object, articleMovementOperationCountService.Object, articleAvailabilityService.Object,
                                                                receiptWaybillService.Object, articleRevaluationService.Object);

            waybill = new WriteoffWaybill("123", DateTime.Now, storage, accOrgSender.Object,
                                          new WriteoffReason(), user.Object, createdBy.Object, DateTime.Now);

            WriteoffWaybillRow row = new WriteoffWaybillRow(receiptWaybillRow.Object, 10);

            waybill.AddRow(row);

            articleMovementService.Setup(x => x.CancelArticleAcceptance(It.IsAny <WriteoffWaybill>()))
            .Returns(new List <OutgoingWaybillRowSourceReservationInfo>()
            {
                new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1)
            });
            articleMovementService.Setup(x => x.AcceptArticles(It.IsAny <WriteoffWaybill>()))
            .Returns(new List <OutgoingWaybillRowSourceReservationInfo>()
            {
                new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1)
            });
        }
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            receiptWaybillRepository            = Mock.Get(IoCContainer.Resolve <IReceiptWaybillRepository>());
            articleRepository                   = Mock.Get(IoCContainer.Resolve <IArticleRepository>());
            storageRepository                   = Mock.Get(IoCContainer.Resolve <IStorageRepository>());
            movementWaybillRepository           = Mock.Get(IoCContainer.Resolve <IMovementWaybillRepository>());
            changeOwnerWaybillRepository        = Mock.Get(IoCContainer.Resolve <IChangeOwnerWaybillRepository>());
            writeoffWaybillRepository           = Mock.Get(IoCContainer.Resolve <IWriteoffWaybillRepository>());
            expenditureWaybillRepository        = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillRepository>());
            returnFromClientWaybillRepository   = Mock.Get(IoCContainer.Resolve <IReturnFromClientWaybillRepository>());
            waybillRowArticleMovementRepository = Mock.Get(IoCContainer.Resolve <IWaybillRowArticleMovementRepository>());

            var incomingWaybillRowService = new IncomingWaybillRowService(receiptWaybillRepository.Object, movementWaybillRepository.Object,
                                                                          changeOwnerWaybillRepository.Object, returnFromClientWaybillRepository.Object);

            var outgoingWaybillRowService = new OutgoingWaybillRowService(movementWaybillRepository.Object, IoCContainer.Resolve <IWriteoffWaybillRepository>(),
                                                                          IoCContainer.Resolve <IExpenditureWaybillRepository>(), changeOwnerWaybillRepository.Object, waybillRowArticleMovementRepository.Object);

            var articleMovementService = new ArticleMovementService(waybillRowArticleMovementRepository.Object, receiptWaybillRepository.Object,
                                                                    movementWaybillRepository.Object, changeOwnerWaybillRepository.Object, returnFromClientWaybillRepository.Object,
                                                                    Mock.Get(IoCContainer.Resolve <IWriteoffWaybillRepository>()).Object, Mock.Get(IoCContainer.Resolve <IExpenditureWaybillRepository>()).Object,
                                                                    incomingWaybillRowService, outgoingWaybillRowService);

            articleAvailabilityService = new ArticleAvailabilityService(receiptWaybillRepository.Object,
                                                                        movementWaybillRepository.Object,
                                                                        changeOwnerWaybillRepository.Object,
                                                                        writeoffWaybillRepository.Object,
                                                                        expenditureWaybillRepository.Object,
                                                                        returnFromClientWaybillRepository.Object,
                                                                        articleRepository.Object,
                                                                        storageRepository.Object,
                                                                        IoCContainer.Resolve <IIncomingAcceptedArticleAvailabilityIndicatorService>(),
                                                                        IoCContainer.Resolve <IOutgoingAcceptedFromExactArticleAvailabilityIndicatorService>(),
                                                                        IoCContainer.Resolve <IOutgoingAcceptedFromIncomingAcceptedArticleAvailabilityIndicatorService>(),
                                                                        IoCContainer.Resolve <IExactArticleAvailabilityIndicatorService>(),
                                                                        incomingWaybillRowService);

            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var physicalLegalForm  = new LegalForm("ИП", EconomicAgentType.PhysicalPerson);

            juridicalPerson = new JuridicalPerson(juridicalLegalForm)
            {
                Id = 1
            };
            physicalPerson = new PhysicalPerson(physicalLegalForm)
            {
                Id = 2
            };

            accountOrganization = new AccountOrganization("Тестовое юридическое лицо", "Тестовое юридическое лицо", juridicalPerson)
            {
                Id = 1
            };
            providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", physicalPerson)
            {
                Id = 2
            };

            provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium, 5);
            provider.AddContractorOrganization(providerOrganization);

            providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today);
            provider.AddProviderContract(providerContract);

            articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа");
            measureUnit  = new MeasureUnit("шт.", "Штука", "123", 0)
            {
                Id = 1
            };

            storageG = new Storage("G", StorageType.DistributionCenter)
            {
                Id = 1
            };
            storageM = new Storage("M", StorageType.DistributionCenter)
            {
                Id = 2
            };
            storageN = new Storage("N", StorageType.DistributionCenter)
            {
                Id = 3
            };

            articleA = new Article("A", articleGroup, measureUnit, false)
            {
                Id = 101
            };
            articleB = new Article("B", articleGroup, measureUnit, false)
            {
                Id = 102
            };
            articleC = new Article("C", articleGroup, measureUnit, false)
            {
                Id = 103
            };

            valueAddedTax = new ValueAddedTax("18%", 18);

            priceLists = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(articleA, 100), new ArticleAccountingPrice(articleB, 200),
                new ArticleAccountingPrice(articleC, 300)
            };
        }
Example #10
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            receiptWaybillRepository = Mock.Get(IoCContainer.Resolve <IReceiptWaybillRepository>());

            receiptWaybillService = new ReceiptWaybillService(IoCContainer.Resolve <IArticleRepository>(),
                                                              receiptWaybillRepository.Object,
                                                              IoCContainer.Resolve <IMovementWaybillRepository>(), IoCContainer.Resolve <IExpenditureWaybillRepository>(),
                                                              IoCContainer.Resolve <IStorageRepository>(), IoCContainer.Resolve <IUserRepository>(),
                                                              IoCContainer.Resolve <IChangeOwnerWaybillRepository>(), IoCContainer.Resolve <IWriteoffWaybillRepository>(),
                                                              IoCContainer.Resolve <IStorageService>(),
                                                              IoCContainer.Resolve <IAccountOrganizationService>(),
                                                              IoCContainer.Resolve <IProviderService>(),
                                                              IoCContainer.Resolve <IProviderContractService>(),
                                                              IoCContainer.Resolve <IValueAddedTaxService>(),
                                                              IoCContainer.Resolve <IArticleMovementService>(),
                                                              IoCContainer.Resolve <IArticlePriceService>(),
                                                              IoCContainer.Resolve <IExactArticleAvailabilityIndicatorService>(),
                                                              IoCContainer.Resolve <IIncomingAcceptedArticleAvailabilityIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleAccountingPriceIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleMovementOperationCountService>(),
                                                              IoCContainer.Resolve <IOutgoingAcceptedFromExactArticleAvailabilityIndicatorService>(),
                                                              IoCContainer.Resolve <IOutgoingAcceptedFromIncomingAcceptedArticleAvailabilityIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleMovementFactualFinancialIndicatorService>(),
                                                              IoCContainer.Resolve <IFactualFinancialArticleMovementService>(),
                                                              IoCContainer.Resolve <IAcceptedSaleIndicatorService>(),
                                                              IoCContainer.Resolve <IShippedSaleIndicatorService>(),
                                                              IoCContainer.Resolve <IReceiptedReturnFromClientIndicatorService>(),
                                                              IoCContainer.Resolve <IAcceptedReturnFromClientIndicatorService>(),
                                                              IoCContainer.Resolve <IReturnFromClientBySaleAcceptanceDateIndicatorService>(),
                                                              IoCContainer.Resolve <IReturnFromClientBySaleShippingDateIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleRevaluationService>(),
                                                              IoCContainer.Resolve <IArticlePurchaseService>(),
                                                              IoCContainer.Resolve <IAcceptedPurchaseIndicatorService>(),
                                                              IoCContainer.Resolve <IApprovedPurchaseIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleAvailabilityService>()
                                                              );

            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var providerType       = new ProviderType("Тестовый тип поставщика");
            var articleGroup       = new ArticleGroup("Бытовая техника", "Бытовая техника");
            var measureUnit        = new MeasureUnit("шт", "штука", "123", 0);
            var article            = new Article("Пылесос", articleGroup, measureUnit, true)
            {
                Id = 1
            };

            priceLists = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(article, 100M)
            };

            var provider = new Provider("Нейтральная организация", providerType, ProviderReliability.Medium, 5);

            var providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", new JuridicalPerson(juridicalLegalForm))
            {
                Id = 1
            };
            var accountOrganization = new AccountOrganization(@"ООО ""Юридическое лицо""", @"ООО ""Юридическое лицо""", new JuridicalPerson(juridicalLegalForm))
            {
                Id = 2
            };

            provider.AddContractorOrganization(providerOrganization);

            var providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today);

            provider.AddProviderContract(providerContract);

            role = new Role("Администратор");
            role.AddPermissionDistribution(new PermissionDistribution(Permission.ReceiptWaybill_Delete_Row_Delete, PermissionDistributionType.All));
            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            user.AddRole(role);
            createdBy = new User(new Employee("Олег", "Олегов", "Олегович", new EmployeePost("Менеджер"), null), "Олегов Олег", "olegov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            createdBy.AddRole(role);
            acceptedBy = new User(new Employee("Петр", "Петров", "Петрович", new EmployeePost("Менеджер"), null), "Петров Петр", "petrov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            acceptedBy.AddRole(role);
            receiptedBy = new User(new Employee("Николай", "Николаев", "Николаевия", new EmployeePost("Менеджер"), null), "Николаев Николай", "nikolaev", "pa$$w0rd", new Team("Тестовая команда", null), null);
            receiptedBy.AddRole(role);

            var customDeclarationNumber = new String('0', 25);

            receiptWaybill    = new ReceiptWaybill("999999", DateTime.Today, new Storage("Третий склад", StorageType.DistributionCenter), accountOrganization, provider, 50, 0M, new ValueAddedTax("10%", 10), providerContract, customDeclarationNumber, user, createdBy, DateTime.Now);
            receiptWaybillRow = new ReceiptWaybillRow(article, 5, 50M, receiptWaybill.PendingValueAddedTax);

            receiptWaybill.AddRow(receiptWaybillRow);

            receiptWaybillList = new List <ReceiptWaybill> {
                receiptWaybill
            };

            receiptWaybillRepository.Setup(x => x.Delete(It.IsAny <ReceiptWaybill>())).Callback <ReceiptWaybill>(waybill => receiptWaybillList.Remove(waybill));
        }
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            storageRepository              = Mock.Get(IoCContainer.Resolve <IStorageRepository>());
            accountingPriceListRepository  = Mock.Get(IoCContainer.Resolve <IAccountingPriceListRepository>());
            articleAvailabilityService     = Mock.Get(IoCContainer.Resolve <IArticleAvailabilityService>());
            articlePriceService            = Mock.Get(IoCContainer.Resolve <IArticlePriceService>());
            accountingPriceCalcRuleService = Mock.Get(IoCContainer.Resolve <IAccountingPriceCalcRuleService>());
            accountingPriceCalcRule        = new Mock <AccountingPriceCalcRule>();
            lastDigitCalcRule              = new Mock <LastDigitCalcRule>();

            accountingPriceCalcService = new AccountingPriceCalcService();

            articleGroup = new ArticleGroup("Бытовая техника", "Бытовая техника");
            articleGroup.MarkupPercent = 25;
            measureUnit = new MeasureUnit("шт.", "Штука", "123", 0)
            {
                Id = 1
            };

            article = new Article("Пылесос", articleGroup, measureUnit, false)
            {
                Id = 101
            };

            priceLists = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(article, 100)
            };

            storageA = new Storage("А", StorageType.TradePoint)
            {
                Id = 1
            };
            storageB = new Storage("Б", StorageType.DistributionCenter)
            {
                Id = 2
            };
            storageC = new Storage("В", StorageType.DistributionCenter)
            {
                Id = 3
            };
            storageA1 = new Storage("А1", StorageType.TradePoint)
            {
                Id = 4
            };
            storageB1 = new Storage("Б1", StorageType.DistributionCenter)
            {
                Id = 5
            };
            storageC1 = new Storage("В1", StorageType.DistributionCenter)
            {
                Id = 6
            };

            storageList = new List <Storage> {
                storageA, storageB, storageC, storageA1, storageB1, storageC1
            };

            storageRepository.Setup(x => x.GetAll()).Returns(storageList);
            storageRepository.Setup(x => x.GetStoragesByType(It.IsAny <StorageType>())).Returns <StorageType>(x => storageList.Where(s => s.Type == x).ToList());

            valueAddedTax = new ValueAddedTax("10%", 10);

            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            var role = new Role("Администратор");

            role.AddPermissionDistribution(new PermissionDistribution(Permission.PurchaseCost_View_ForEverywhere, PermissionDistributionType.All));
            role.AddPermissionDistribution(new PermissionDistribution(Permission.AccountingPrice_NotCommandStorage_View, PermissionDistributionType.All));
            user.AddRole(role);
        }
 public ProductionOrderServiceTest()
 {
     // инициализация IoC
     IoCInitializer.Init();
 }
 public BaseArticleRevaluationIndicatorServiceTest()
 {
     // инициализация IoC
     IoCInitializer.Init();
 }
Example #14
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            setting = new Setting()
            {
                UseReadyToAcceptStateForExpenditureWaybill = false
            };
            settingRepository = Mock.Get(IoCContainer.Resolve <ISettingRepository>());
            settingRepository.Setup(x => x.Get()).Returns(setting);

            storage = new Storage("qwe", StorageType.ExtraStorage)
            {
                Id = 42
            };
            accOrgSender = new Mock <AccountOrganization>();
            accOrgSender.Setup(x => x.Id).Returns(1);
            accOrgRecipient = new Mock <AccountOrganization>();
            accOrgRecipient.Setup(x => x.Id).Returns(2);

            valueAddedTax = new ValueAddedTax();
            user          = new Mock <User>();
            user.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);
            createdBy = new Mock <User>();
            createdBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);
            acceptedBy = new Mock <User>();
            acceptedBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All);

            var articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа");
            var measureUnit  = new MeasureUnit("шт.", "Штука", "123", 0)
            {
                Id = 1
            };

            articleA = new Article("Тестовый товар A", articleGroup, measureUnit, true)
            {
                Id = 1
            };

            receiptWaybillRow = new Mock <ReceiptWaybillRow>();
            receiptWaybillRow.Setup(x => x.Article).Returns(articleA);

            articleAccountingPrice = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(articleA, 100)
            };

            expenditureWaybillRepository = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillRepository>());
            articleRepository            = Mock.Get(IoCContainer.Resolve <IArticleRepository>());
            articlePriceService          = Mock.Get(IoCContainer.Resolve <IArticlePriceService>());
            articlePriceService.Setup(x => x.GetArticleAccountingPrices(It.Is <short>(y => y == storage.Id), It.IsAny <IEnumerable <int> >())).Returns(articleAccountingPrice);
            articlePriceService.Setup(x => x.GetArticleAccountingPrices(It.Is <short>(y => y == storage.Id), It.IsAny <ISubQuery>(), It.IsAny <DateTime>())).Returns(articleAccountingPrice);

            articleAvailabilityService = Mock.Get(IoCContainer.Resolve <IArticleAvailabilityService>());

            articleMovementService = Mock.Get(IoCContainer.Resolve <IArticleMovementService>());

            receiptWaybillService = Mock.Get(IoCContainer.Resolve <IReceiptWaybillService>());

            articleRevaluationService = Mock.Get(IoCContainer.Resolve <IArticleRevaluationService>());

            factualFinancialArticleMovementService = new Mock <IFactualFinancialArticleMovementService>();

            articleMovementOperationCountService = new Mock <IArticleMovementOperationCountService>();

            teamRepository = Mock.Get(IoCContainer.Resolve <ITeamRepository>());

            dealRepository = Mock.Get(IoCContainer.Resolve <IDealRepository>());

            expenditureWaybillIndicatorService = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillIndicatorService>());

            dealPaymentDocumentDistributionService = Mock.Get(IoCContainer.Resolve <IDealPaymentDocumentDistributionService>());

            blockingService = Mock.Get(IoCContainer.Resolve <IBlockingService>());

            articleSaleService                = Mock.Get(IoCContainer.Resolve <IArticleSaleService>());
            teamService                       = Mock.Get(IoCContainer.Resolve <ITeamService>());
            dealService                       = Mock.Get(IoCContainer.Resolve <IDealService>());
            dealIndicatorService              = Mock.Get(IoCContainer.Resolve <IDealIndicatorService>());
            clientContractIndicatorService    = Mock.Get(IoCContainer.Resolve <IClientContractIndicatorService>());
            returnFromClientWaybillRepository = new Mock <IReturnFromClientWaybillRepository>();

            expenditureWaybillService = new ExpenditureWaybillService(settingRepository.Object, expenditureWaybillRepository.Object, teamRepository.Object,
                                                                      Mock.Get(IoCContainer.Resolve <IStorageRepository>()).Object, Mock.Get(IoCContainer.Resolve <IUserRepository>()).Object,
                                                                      dealRepository.Object, articlePriceService.Object, expenditureWaybillIndicatorService.Object, articleMovementService.Object,
                                                                      dealPaymentDocumentDistributionService.Object, blockingService.Object, articleSaleService.Object,
                                                                      factualFinancialArticleMovementService.Object, articleMovementOperationCountService.Object, teamService.Object, dealService.Object,
                                                                      dealIndicatorService.Object, clientContractIndicatorService.Object, articleAvailabilityService.Object,
                                                                      receiptWaybillService.Object, articleRevaluationService.Object, returnFromClientWaybillRepository.Object);

            deal                = new Mock <Deal>();
            quota               = new DealQuota("asd", 10, 45, 15000);
            team                = new Mock <Team>();
            contract            = new Mock <ClientContract>();
            accountOrganization = new Mock <AccountOrganization>();
            deal.Setup(x => x.IsActive).Returns(true);
            deal.Setup(x => x.IsClosed).Returns(false);
            deal.Setup(x => x.Quotas).Returns(new List <DealQuota> {
                quota
            });
            deal.Setup(x => x.Contract).Returns(contract.Object);
            accountOrganization.Setup(x => x.Storages).Returns(new List <Storage> {
                storage
            });
            contract.Setup(x => x.AccountOrganization).Returns(accountOrganization.Object);

            waybill = new ExpenditureWaybill("123", DateTime.Now, storage, deal.Object, team.Object, quota, false, user.Object, DeliveryAddressType.CustomAddress, "qwe", DateTime.Now, createdBy.Object);

            var row = new ExpenditureWaybillRow(receiptWaybillRow.Object, 10, valueAddedTax);

            waybill.AddRow(row);

            articleMovementService.Setup(x => x.CancelArticleAcceptance(It.IsAny <ExpenditureWaybill>()))
            .Returns(new List <OutgoingWaybillRowSourceReservationInfo>()
            {
                new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1)
            });
            articleMovementService.Setup(x => x.AcceptArticles(It.IsAny <ExpenditureWaybill>()))
            .Returns(new List <OutgoingWaybillRowSourceReservationInfo>()
            {
                new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1)
            });
        }
 public DealPaymentDocumentDistributionServiceTest()
 {
     // инициализация IoC
     IoCInitializer.Init();
 }