/// <summary>
        /// Gets the economics group asynchronous.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="isAdmin">if set to <c>true</c> [is admin].</param>
        /// <returns></returns>
        public async Task <IList <EconomicGroupDto> > GetEconomicsGroupAsync(string userId, bool isAdmin)
        {
            IList <EconomicGroup> economicGroups = isAdmin ?
                                                   await economicGroupRepository.GetEconomicsGroupAsync().ConfigureAwait(false) :
                                                   await economicGroupRepository.GetEconomicsGroupAsync(userId).ConfigureAwait(false);

            if (economicGroups.Any())
            {
                var firstGroupId = economicGroups.OrderBy(x => x.EconomicGroupName).FirstOrDefault().Id;
                var groupId      = cache.Find($"{Constant.ECONMIC_GROUP_ID_CACHE_NAME}{userId}", () => firstGroupId);
                var existGroup   = economicGroups.Any(t => t.Id == groupId);
                if (!existGroup)
                {
                    cache.Set($"{Constant.ECONMIC_GROUP_ID_CACHE_NAME}{userId}", groupId);
                    groupId = firstGroupId;
                }

                foreach (var economicGroup in economicGroups.Where(economicGroup => economicGroup.Id == groupId))
                {
                    economicGroup.Selected = true;
                }
            }

            return(mapper.Map <IList <EconomicGroupDto> >(economicGroups));
        }
        public void GetListEconomicGroups_GivenUserAsAdmin_ReturnListWithThreeEconomicGroups()
        {
            // Arrage
            int processed = 0;
            var userId    = "810";
            var isAdmin   = true;

            var listEconomicGroupSpected = EconomicGroupServiceData.GetListEconomicGroupWithThreeElements();

            economicGroupRepository.GetEconomicsGroupAsync().Returns(listEconomicGroupSpected);
            economicGroupRepository.When(fx => fx.GetEconomicsGroupAsync()).Do(fx => ++ processed);

            // Act
            var economicGroupSpectedTask = economicGroupService.GetEconomicsGroupAsync(userId, isAdmin);

            economicGroupSpectedTask.Wait();

            // Assert
            Assert.IsTrue(economicGroupSpectedTask.Status == TaskStatus.RanToCompletion);
            Assert.IsNotNull(economicGroupSpectedTask.Result);
            Assert.AreEqual(3, economicGroupSpectedTask.Result.Count);
            Assert.AreEqual(1, processed);
            economicGroupRepository.Received(1).GetEconomicsGroupAsync();
        }