public AddDataForTestingTransaction()
 {
     ConnectionManager connectionManager = ConnectionManager.GetInstance(DataUtil.TESTDB);
     _connection = connectionManager.SqlConnection;
     _domainOfApplicationManagement = new EconomicActivityManager(DataUtil.TESTDB);
     _clientManagement = new ClientManager(DataUtil.TESTDB);
     _branch = new Branch {Id = 1, Name = "Default"};
 }
 public void AddEconomicActivityWithoutChildren()
 {
     _economicActivityManager = (EconomicActivityManager) container["EconomicActivityManager"];
     EconomicActivity activity = new EconomicActivity
                                     {
                                         Name = "Services",
                                         Parent = null
                                     };
     activity.Id = _economicActivityManager.AddEconomicActivity(activity);
     Assert.AreNotEqual(0,activity.Id);
 }
Esempio n. 3
0
        public void InitManager()
        {
            TechnicalSettings.CheckSettings();

            LoanProductManager loanProductManager = new LoanProductManager(DataUtil.TESTDB);
            AccountingTransactionManager accountingTransactionManager = new AccountingTransactionManager(DataUtil.TESTDB);
            EventManager eventManager = new EventManager(DataUtil.TESTDB);
            ExchangeRateManager exchangeRateManager = new ExchangeRateManager(DataUtil.TESTDB);
            ProvisioningRuleManager provisioningRuleManager = new ProvisioningRuleManager(DataUtil.TESTDB);
            AccountManager accountManager = new AccountManager(DataUtil.TESTDB);
            InstallmentTypeManager installmentTypeManager = new InstallmentTypeManager(DataUtil.TESTDB);
            UserManager userManager = new UserManager(DataUtil.TESTDB);
            EconomicActivityManager economicActivityManager = new EconomicActivityManager(DataUtil.TESTDB);
            InstallmentManager installmentManager = new InstallmentManager(DataUtil.TESTDB);
            FundingLineManager fundingLineManager = new FundingLineManager(DataUtil.TESTDB);
            ClientManager clientManager = new ClientManager(DataUtil.TESTDB);
            LocationsManager locationsManager = new LocationsManager(DataUtil.TESTDB);
            LoanManager loanManager = new LoanManager(DataUtil.TESTDB);
            ProjectManager projectManager = new ProjectManager(DataUtil.TESTDB);
            MFIManager mfiManager = new MFIManager(DataUtil.TESTDB);
            SavingManager savingManager = new SavingManager(DataUtil.TESTDB);
            SavingProductManager savingProductManager = new SavingProductManager(DataUtil.TESTDB);
            SavingEventManager savingEventManager = new SavingEventManager(DataUtil.TESTDB);
            CurrencyManager currencyManager = new CurrencyManager(DataUtil.TESTDB);
            AccountingRuleManager accountingRuleManager = new AccountingRuleManager(DataUtil.TESTDB);
            FundingLineServices fundingLineServices = new FundingLineServices(DataUtil.TESTDB);

            container = new Hashtable
                            {
                                {"LoanProductManager", loanProductManager},
                                {"AccountingTransactionManager", accountingTransactionManager},
                                {"EventManager", eventManager},
                                {"ExchangeRateManager", exchangeRateManager},
                                {"ProvisioningRuleManager", provisioningRuleManager},
                                {"AccountManager", accountManager},
                                {"InstallmentTypeManager", installmentTypeManager},
                                {"UserManager", userManager},
                                {"FundingLineManager", fundingLineManager},
                                {"LoanManager", loanManager},
                                {"ClientManager", clientManager},
                                {"LocationsManager", locationsManager},
                                {"ProjectManager", projectManager},
                                {"EconomicActivityManager", economicActivityManager},
                                {"InstallmentManager", installmentManager},
                                {"MFIManager", mfiManager},
                                {"SavingManager", savingManager},
                                {"SavingProductManager", savingProductManager},
                                {"SavingEventManager", savingEventManager},
                                {"CurrencyManager", currencyManager},
                                {"FundingLineServices", fundingLineServices},
                                {"AccountingRuleManager", accountingRuleManager}
                            };
        }
        public void AddEconomicActivityWhenNameAlreadyExist()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activity = new EconomicActivity { Name = "Services", Parent = new EconomicActivity { Id = 1 } };

            _dynamicMock.ExpectAndReturn("ThisActivityAlreadyExist", true, "Services", 1);
            _dynamicMock.ExpectAndReturn("AddEconomicActivity", 0, activity);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            _economicActivityServices.AddEconomicActivity(activity);
        }
        public void AddEconomicActivity()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activity = new EconomicActivity { Name = "Services",Parent = new EconomicActivity {Id=1}};

            _dynamicMock.ExpectAndReturn("ThisActivityAlreadyExist", false, "Services", 1);
            _dynamicMock.ExpectAndReturn("AddEconomicActivity", 2, activity);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            activity.Id = _economicActivityServices.AddEconomicActivity(activity);
            Assert.AreEqual(2,activity.Id);
        }
        public void SelectAllEconomicActivities()
        {
            _economicActivityManager = (EconomicActivityManager)container["EconomicActivityManager"];
            EconomicActivity activityParentA = new EconomicActivity
            {
                Name = "Services",
                Parent = null
            };
            activityParentA.Id = _economicActivityManager.AddEconomicActivity(activityParentA);
            EconomicActivity activityParentB = new EconomicActivity
            {
                Name = "Services",
                Parent = null
            };
            activityParentB.Id = _economicActivityManager.AddEconomicActivity(activityParentB);
            EconomicActivity activityA = new EconomicActivity
            {
                Name = "ServicesA",
                Parent = activityParentA,
            };
            activityA.Id = _economicActivityManager.AddEconomicActivity(activityA);
            EconomicActivity activityB = new EconomicActivity
            {
                Name = "ServicesB",
                Parent = activityParentA,
            };
            activityB.Id = _economicActivityManager.AddEconomicActivity(activityB);

            List<EconomicActivity> activities = _economicActivityManager.SelectAllEconomicActivities();

            Assert.AreEqual(4, activities.Count);

            Assert.AreEqual(false, activities[0].HasChildrens);
            Assert.AreEqual(0, activities[0].Childrens.Count);

            Assert.AreEqual(false, activities[1].HasChildrens);
            Assert.AreEqual(0, activities[1].Childrens.Count);

            Assert.AreEqual(true, activities[2].HasChildrens);
            Assert.AreEqual(2, activities[2].Childrens.Count);

            Assert.AreEqual(false, activities[3].HasChildrens);
            Assert.AreEqual(0, activities[3].Childrens.Count);
        }
Esempio n. 7
0
 public DataHelper()
 {
     _domainOfApplicationManagement = new EconomicActivityManager(DataUtil.TESTDB);
     _userManager = new UserManager(DataUtil.TESTDB);
 }
        public void UpdateEconomicActivity()
        {
            _economicActivityManager = (EconomicActivityManager)container["EconomicActivityManager"];
            EconomicActivity activity = new EconomicActivity
            {
                Name = "Services",
                Parent = null
            };
            activity.Id = _economicActivityManager.AddEconomicActivity(activity);

            activity.Name = "NewServices";
            activity.Deleted = true;
            _economicActivityManager.UpdateEconomicActivity(activity);

            EconomicActivity selectedActivity = _economicActivityManager.SelectEconomicActivity(activity.Id);
            Assert.AreEqual(activity.Id, selectedActivity.Id);
            Assert.AreEqual("NewServices", selectedActivity.Name);
            Assert.AreEqual(true, selectedActivity.Deleted);
        }
        public void FindAllEconomicActivitiesWhithoutResult()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            List<EconomicActivity> activities = new List<EconomicActivity> ();

            _dynamicMock.SetReturnValue("SelectAllEconomicActivities", activities);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            Assert.AreEqual(0, _economicActivityServices.FindAllEconomicActivities().Count);
        }
Esempio n. 10
0
 public EconomicActivityServices(string pTestDb)
 {
     _doam = new EconomicActivityManager(pTestDb);
 }
        public void AddEconomicActivityWhenNameIsEmpty()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activity = new EconomicActivity { Name = String.Empty };

            _dynamicMock.ExpectAndReturn("AddEconomicActivity",0, activity);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            _economicActivityServices.AddEconomicActivity(activity);
        }
        public void UpdateEconomicActivityButNewNameAlreadyExist()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activity = new EconomicActivity { Name = "Services", Parent = new EconomicActivity { Id = 1 } };

            _dynamicMock.Expect("UpdateEconomicActivity", activity);
            _dynamicMock.ExpectAndReturn("ThisActivityAlreadyExist", true, "Services", 1);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            _economicActivityServices.ChangeDomainOfApplicationName(activity, "Services");
        }
        public void TestDeleteDomainWhenDomainHasNoChildrens()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activity = new EconomicActivity { Id = 1, Name = "Services", Childrens = new List<EconomicActivity>()};

            _dynamicMock.Expect("UpdateEconomicActivity",activity);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            _economicActivityServices.DeleteEconomicActivity(activity);
        }
        public void TestChangeDomainOfApplicationNameWhenNotInUse()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activity = new EconomicActivity { Id = 2, Name = "Services",Parent = new EconomicActivity { Id = 1 }};

            _dynamicMock.Expect("UpdateEconomicActivity", activity);
            _dynamicMock.ExpectAndReturn("ThisActivityAlreadyExist", false, "GMO agriculture", 1);
            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);
            Assert.AreEqual(true, _economicActivityServices.ChangeDomainOfApplicationName(activity, "GMO agriculture"));
        }
Esempio n. 15
0
        protected override void SetUp()
        {
            base.SetUp();

            _accountingRuleManager = (AccountingRuleManager)container["AccountingRuleManager"];
            _accountManager = (AccountManager)container["AccountManager"];
            _loanProductManager = (LoanProductManager)container["LoanProductManager"];
            _savingProductManager = (SavingProductManager)container["SavingProductManager"];
            _economicActivityManager = (EconomicActivityManager)container["EconomicActivityManager"];
            _fundingLineManager = (FundingLineManager)container["FundingLineManager"];
            _eventManager = (EventManager)container["EventManager"];

            Assert.IsNotNull(_accountingRuleManager);
            Assert.IsNotNull(_accountManager);
            Assert.IsNotNull(_loanProductManager);
            Assert.IsNotNull(_savingProductManager);
            Assert.IsNotNull(_economicActivityManager);
            Assert.IsNotNull(_fundingLineManager);
            Assert.IsNotNull(_eventManager);
        }
Esempio n. 16
0
 public EconomicActivityServices(User pUser)
 {
     _doam = new EconomicActivityManager(pUser);
 }
        public void SelectEconomicActivityByIdWithChildren()
        {
            _economicActivityManager = (EconomicActivityManager)container["EconomicActivityManager"];
            EconomicActivity activityParent = new EconomicActivity
            {
                Name = "Services",
                Parent = null
            };
            activityParent.Id = _economicActivityManager.AddEconomicActivity(activityParent);
            EconomicActivity activityA = new EconomicActivity
            {
                Name = "ServicesA",
                Parent = activityParent,
            };
            activityA.Id = _economicActivityManager.AddEconomicActivity(activityA);
            EconomicActivity activityB = new EconomicActivity
            {
                Name = "ServicesB",
                Parent = activityParent,
            };
            activityB.Id = _economicActivityManager.AddEconomicActivity(activityB);

            EconomicActivity selectedActivity = _economicActivityManager.SelectEconomicActivity(activityParent.Id);

            Assert.AreEqual(activityParent.Id, selectedActivity.Id);
            Assert.AreEqual("Services", selectedActivity.Name);
            Assert.AreEqual(true, selectedActivity.HasChildrens);
            Assert.AreEqual(2, selectedActivity.Childrens.Count);
            Assert.AreEqual(false, selectedActivity.Deleted);
        }
Esempio n. 18
0
 public EconomicActivityServices(EconomicActivityManager doam)
 {
     _doam = doam;
 }
        public void SelectEconomicActivityByIdWithoutChildren()
        {
            _economicActivityManager = (EconomicActivityManager)container["EconomicActivityManager"];
            EconomicActivity activity = new EconomicActivity
            {
                Name = "Services",
                Parent = null
            };
            activity.Id = _economicActivityManager.AddEconomicActivity(activity);
            Assert.AreNotEqual(0, activity.Id);

            EconomicActivity selectedActivity = _economicActivityManager.SelectEconomicActivity(activity.Id);
            Assert.AreEqual(activity.Id,selectedActivity.Id);
            Assert.AreEqual("Services",selectedActivity.Name);
            Assert.AreEqual(false, selectedActivity.HasChildrens);
            Assert.AreEqual(0,selectedActivity.Childrens.Count);
        }
        public void ThisActivityAlreadyExistInThisActivity()
        {
            _economicActivityManager = (EconomicActivityManager)container["EconomicActivityManager"];
            EconomicActivity activityParentA = new EconomicActivity
            {
                Name = "Services",
                Parent = null
            };
            activityParentA.Id = _economicActivityManager.AddEconomicActivity(activityParentA);
            EconomicActivity activityParentB = new EconomicActivity
            {
                Name = "Services",
                Parent = null
            };
            activityParentB.Id = _economicActivityManager.AddEconomicActivity(activityParentB);
            EconomicActivity activityA = new EconomicActivity
            {
                Name = "ServicesA",
                Parent = activityParentA,
            };
            activityA.Id = _economicActivityManager.AddEconomicActivity(activityA);

            Assert.AreEqual(true, _economicActivityManager.ThisActivityAlreadyExist("ServicesA", activityParentA.Id));
        }
        public void FindAllEconomicActivitiesWhenResult()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activityA1 = new EconomicActivity { Id = 3, Name = "ServicesA1" };
            EconomicActivity activityB2 = new EconomicActivity { Id = 4, Name = "ServicesB2" };
            EconomicActivity activityA = new EconomicActivity { Id = 1,Name = "ServicesA", Parent = null ,Childrens = new List<EconomicActivity>{activityA1,activityB2}};
            EconomicActivity activityB = new EconomicActivity { Id = 2, Name = "ServicesB", Parent = null };

            List<EconomicActivity> activities = new List<EconomicActivity> {activityA, activityB};

            _dynamicMock.SetReturnValue("SelectAllEconomicActivities", activities);

            _economicActivityManager = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            Assert.AreEqual(2, _economicActivityServices.FindAllEconomicActivities().Count);
        }