public static void SeedOperators(IOperatorManager operatorManager, ICodeManager codeManager, ITariffManager tariffManager)
        {
            if (operatorManager.GetByName("Vodafone") == null)
            {
                OperatorViewModel oper1 = new OperatorViewModel();
                oper1.Name = "Vodafone";
                operatorManager.Add(oper1);
                oper1 = operatorManager.GetByName("Vodafone");

                CodeViewModel code1 = new CodeViewModel()
                {
                    OperatorId = oper1.Id, OperatorCode = "+38099"
                };
                CodeViewModel code2 = new CodeViewModel()
                {
                    OperatorId = oper1.Id, OperatorCode = "+38066"
                };
                CodeViewModel code3 = new CodeViewModel()
                {
                    OperatorId = oper1.Id, OperatorCode = "+38050"
                };

                codeManager.Add(code1);
                codeManager.Add(code2);
                codeManager.Add(code3);

                SeedTariffs(tariffManager, oper1.Id);
            }

            if (operatorManager.GetByName("Kyivstar") == null)
            {
                OperatorViewModel oper2 = new OperatorViewModel();
                oper2.Name = "Kyivstar";
                operatorManager.Add(oper2);
                oper2 = operatorManager.GetByName("Kyivstar");

                CodeViewModel code4 = new CodeViewModel()
                {
                    OperatorId = oper2.Id, OperatorCode = "+38097"
                };
                CodeViewModel code5 = new CodeViewModel()
                {
                    OperatorId = oper2.Id, OperatorCode = "+38067"
                };
                CodeViewModel code6 = new CodeViewModel()
                {
                    OperatorId = oper2.Id, OperatorCode = "+38096"
                };

                codeManager.Add(code4);
                codeManager.Add(code5);
                codeManager.Add(code6);

                SeedTariffs(tariffManager, oper2.Id);
            }
        }
Ejemplo n.º 2
0
        public void GetByName_GettingOperators_SuccessResult()
        {
            Operator item = new Operator()
            {
                Name = "name"
            };
            OperatorViewModel itemView = new OperatorViewModel()
            {
                Name = "name"
            };
            List <Operator> operatorsList = new List <Operator>()
            {
                new Operator()
                {
                    Name = "name"
                }
            };

            mockUnitOfWork.Setup(n => n.Operators.Get(It.IsAny <Expression <Func <Operator, bool> > >(), null, ""))
            .Returns(operatorsList);
            mockMapper.Setup(m => m.Map <OperatorViewModel>(It.IsAny <Operator>())).Returns(itemView);

            var result = manager.GetByName("name");

            Assert.That(result, Is.EqualTo(itemView));
        }