Ejemplo n.º 1
0
        public void GetListRecordTypeIdForAccountWithoutValidation_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();

            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeByAccountId(It.IsAny <int>()))
            .Returns(TestHelper.CreateRecordTypeDbOs);

            var losRepository = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var mockMapper = new Mock <IMapper>();

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var recordTypeService = new RecordTypeService(recordTypeRepositoryMock.Object, mockMapper.Object, shareService);
            var result            = recordTypeService.GetListRecordTypeIdForAccountWithoutValidation("2763");

            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result.ElementAt(0), 19386);
        }
Ejemplo n.º 2
0
        public void AccountById_AccountMustExist_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(false);
            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetAccountById("27634");
        }
Ejemplo n.º 3
0
        public void AccountById_AccountLessThan0_Test()
        {
            // shared service
            var accountRepositoryMock    = new Mock <IAccountRepository>();
            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetAccountById("-1");
        }
Ejemplo n.º 4
0
        public void GetRecordTypes_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);
            var accountIds = new List <int>();

            accountIds.Add(2763);
            accountRepositoryMock.Setup(x => x.GetAllAccountIds(It.IsAny <bool>())).Returns(accountIds);

            var accountEntities = new List <AccountDbO>();

            accountEntities.Add(TestHelper.CreateAccountDbO());
            accountRepositoryMock.Setup(x => x.GetAccountEntities(It.IsAny <bool>())).Returns(accountEntities);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            losRepository.Setup(x => x.GetLosById(It.IsAny <int>())).Returns(new LosDbO {
                LosName = "Encompass"
            });

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();

            recordTypeServiceMock.Setup(x => x.GetListRecordTypeForAccountWithoutValidation(It.IsAny <string>())).Returns(TestHelper.CreateRecordTypes());

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <AccountDbO, Api.Service.Models.Response.Account>(It.IsAny <AccountDbO>()))
            .Returns(TestHelper.CreateAccount());

            var accounts = new List <Api.Service.Models.Response.Account>();

            accounts.Add(TestHelper.CreateAccount());

            mockMapper.Setup(x => x.Map <List <AccountDbO>, List <Api.Service.Models.Response.Account> >(It.IsAny <List <AccountDbO> >()))
            .Returns(accounts);

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetRecordTypes("2763");

            Assert.AreEqual(result.Count, accountIds.Count);
            Assert.AreEqual(result.ElementAt(0).AccountId, 2763);
            Assert.AreEqual(result.ElementAt(0).Indicator, "C");
            Assert.AreEqual(result.ElementAt(0).Description, "Customers");
        }
Ejemplo n.º 5
0
        public void GetRecordTypeByAccountIdAndId_RecordTypeId_IdExistsButNotInAccount()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);
            var accountIds = new List <int>();

            accountIds.Add(2763);
            accountRepositoryMock.Setup(x => x.GetAllAccountIds(It.IsAny <bool>())).Returns(accountIds);

            var accountEntities = new List <AccountDbO>();

            accountEntities.Add(TestHelper.CreateAccountDbO());
            accountRepositoryMock.Setup(x => x.GetAccountEntities(It.IsAny <bool>())).Returns(accountEntities);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();

            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeById(It.IsAny <int>())).Returns(TestHelper.CreateRecordTypeDbO());
            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeByAccountIdAndId(It.IsAny <int>(), It.IsAny <int>())).Returns((RecordTypeDbO)null);

            var losRepository = new Mock <ILosRepository>();

            losRepository.Setup(x => x.GetLosById(It.IsAny <int>())).Returns(new LosDbO {
                LosName = "Encompass"
            });

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();

            recordTypeServiceMock.Setup(x => x.GetListRecordTypeIdForAccountWithoutValidation(It.IsAny <string>())).Returns(TestHelper.CreateRecordTypeIds());

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <AccountDbO, Api.Service.Models.Response.Account>(It.IsAny <AccountDbO>()))
            .Returns(TestHelper.CreateAccount());

            var accounts = new List <Api.Service.Models.Response.Account>();

            accounts.Add(TestHelper.CreateAccount());

            mockMapper.Setup(x => x.Map <List <AccountDbO>, List <Api.Service.Models.Response.Account> >(It.IsAny <List <AccountDbO> >()))
            .Returns(accounts);

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetRecordTypeByAccountIdAndId(It.IsAny <string>(), "27634");
        }
Ejemplo n.º 6
0
        public void GetUserByAccountIdAndIdWithoutValidation_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);

            var userRepositoryMock = new Mock <IUserRepository>();

            userRepositoryMock.Setup(x => x.GetUsersByAccountId(It.IsAny <int>(), It.IsAny <bool>()))
            .Returns(TestHelper.CreateAccountUserDbOs());
            userRepositoryMock.Setup(x => x.CheckUserExistsByUserId(It.IsAny <int>()))
            .Returns(true);
            userRepositoryMock.Setup(x => x.GetUserById(It.IsAny <int>())).Returns(TestHelper.CreateUserDbO);
            userRepositoryMock.Setup(x => x.GetLosUserNames(It.IsAny <int>())).Returns(TestHelper.CreateLosUsernNames);
            userRepositoryMock.Setup(x => x.GetAcountUserEntity(It.IsAny <int>())).Returns(TestHelper.CreateAccountUserEntity);

            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <AccountUserDbO>, List <AccountUser> >(It.IsAny <List <AccountUserDbO> >()))
            .Returns(TestHelper.CreateAccountUsers());
            mockMapper.Setup(x => x.Map <UserDbO, User>(It.IsAny <UserDbO>()))
            .Returns(TestHelper.CreateUser);

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountServiceMock = new Mock <IAccountService>();

            accountServiceMock.Setup(x => x.GetAccountIds(It.IsAny <bool>())).Returns(TestHelper.CreateAccountIds());

            var userService = new UserService(userRepositoryMock.Object, mockMapper.Object, shareService, accountServiceMock.Object);
            var result      = userService.GetUserByAccountIdAndIdWithoutValidation("2763", "2147335016");

            Assert.AreEqual(result.FirstName, "Jamie");
            Assert.AreEqual(result.LastName, "Crown");
            Assert.AreEqual(result.Email, "*****@*****.**");
            Assert.AreEqual(result.Business, "314-987-6543");
            Assert.AreEqual(result.UserId, 2147335016);
        }
Ejemplo n.º 7
0
        public void GetUserById_ValidUserId()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);

            var userRepositoryMock = new Mock <IUserRepository>();

            userRepositoryMock.Setup(x => x.GetUsersByAccountId(It.IsAny <int>(), It.IsAny <bool>()))
            .Returns(TestHelper.CreateAccountUserDbOs());
            userRepositoryMock.Setup(x => x.CheckUserExistsByUserId(It.IsAny <int>()))
            .Returns(true);
            userRepositoryMock.Setup(x => x.GetUserById(It.IsAny <int>())).Returns(TestHelper.CreateUserDbO);
            userRepositoryMock.Setup(x => x.GetLosUserNames(It.IsAny <int>())).Returns(TestHelper.CreateLosUsernNames);
            userRepositoryMock.Setup(x => x.GetAcountUserEntity(It.IsAny <int>())).Returns(TestHelper.CreateAccountUserEntity);

            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <AccountUserDbO>, List <AccountUser> >(It.IsAny <List <AccountUserDbO> >()))
            .Returns(TestHelper.CreateAccountUsers());
            mockMapper.Setup(x => x.Map <UserDbO, User>(It.IsAny <UserDbO>()))
            .Returns(TestHelper.CreateUser);

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountServiceMock = new Mock <IAccountService>();

            accountServiceMock.Setup(x => x.GetAccountIds(It.IsAny <bool>())).Returns(TestHelper.CreateAccountIds());

            var userService = new UserService(userRepositoryMock.Object, mockMapper.Object, shareService, accountServiceMock.Object);
            var result      = userService.GetUserById("2147335016");

            Assert.AreEqual(result.UserId, 2147335016);
            Assert.AreEqual(result.AccountAdmin, null);
            Assert.AreEqual(result.LosUserNames.Count, 1);
            Assert.AreEqual(result.MayEnterRates, true);
            Assert.AreEqual(result.MayViewOtherLoHotlists, false);
        }
Ejemplo n.º 8
0
        public void AccountByIds_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);
            var accountIds = new List <int>();

            accountIds.Add(2763);
            accountIds.Add(2764);
            accountRepositoryMock.Setup(x => x.GetAllAccountIds(It.IsAny <bool>())).Returns(accountIds);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            losRepository.Setup(x => x.GetLosById(It.IsAny <int>())).Returns(new LosDbO {
                LosName = "Encompass"
            });

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <AccountDbO, Api.Service.Models.Response.Account>(It.IsAny <AccountDbO>()))
            .Returns(TestHelper.CreateAccount());


            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetAccountIds(true);

            Assert.AreEqual(result.Count, accountIds.Count);
            Assert.AreEqual(result.ElementAt(0), accountIds.ElementAt(0));
        }
Ejemplo n.º 9
0
        public void GetUsers_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);

            var userRepositoryMock = new Mock <IUserRepository>();

            userRepositoryMock.Setup(x => x.GetUsersByAccountId(It.IsAny <int>(), It.IsAny <bool>()))
            .Returns(TestHelper.CreateAccountUserDbOs());

            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <AccountUserDbO>, List <AccountUser> >(It.IsAny <List <AccountUserDbO> >()))
            .Returns(TestHelper.CreateAccountUsers());

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountServiceMock = new Mock <IAccountService>();

            accountServiceMock.Setup(x => x.GetAccountIds(It.IsAny <bool>())).Returns(TestHelper.CreateAccountIds());

            var userService = new UserService(userRepositoryMock.Object, mockMapper.Object, shareService, accountServiceMock.Object);

            var result = userService.GetUsers(It.IsAny <bool>());

            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result.ElementAt(0).AccountId, 2763);
            Assert.AreEqual(result.ElementAt(0).UserId, 2147335016);
        }
Ejemplo n.º 10
0
        public void GetRecordTypeById_Valid()
        {
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();

            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeById(It.IsAny <int>()))
            .Returns(TestHelper.CreateRecordTypeDbO);
            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeByAccountIdAndId(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(TestHelper.CreateRecordTypeDbO);

            var losRepository = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <RecordTypeDbO>, List <RecordType> >(It.IsAny <List <RecordTypeDbO> >()))
            .Returns(TestHelper.CreateRecordTypes);
            mockMapper.Setup(x => x.Map <RecordTypeDbO, RecordType>(It.IsAny <RecordTypeDbO>()))
            .Returns(TestHelper.CreateRecordType);

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var recordTypeService = new RecordTypeService(recordTypeRepositoryMock.Object, mockMapper.Object, shareService);
            var result            =
                recordTypeService.GetRecordTypeById("19386");

            Assert.AreEqual(result.Id, 19386);
            Assert.AreEqual(result.Indicator, "C");
            Assert.AreEqual(result.Name, "Customers");
            Assert.AreEqual(result.Description, "Customers");
        }
Ejemplo n.º 11
0
        public void AccountById_AccoutValidAccount_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);
            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            losRepository.Setup(x => x.GetLosById(It.IsAny <int>())).Returns(new LosDbO {
                LosName = "Encompass"
            });

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <AccountDbO, Api.Service.Models.Response.Account>(It.IsAny <AccountDbO>()))
            .Returns(TestHelper.CreateAccount());


            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetAccountById("2763");

            Assert.AreEqual(result.AccountId, 2763);
            Assert.AreEqual(result.ClientLoanOriginationSystem, "Encompass");
            Assert.AreEqual(result.EnablePremiumService, "Yes");
        }
Ejemplo n.º 12
0
        public void GetRecordTypeById_RecordTypeLessThan0()
        {
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();

            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeById(It.IsAny <int>()))
            .Returns(TestHelper.CreateRecordTypeDbO);
            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeByAccountIdAndId(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(TestHelper.CreateRecordTypeDbO);

            var losRepository = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <RecordTypeDbO>, List <RecordType> >(It.IsAny <List <RecordTypeDbO> >()))
            .Returns(TestHelper.CreateRecordTypes);
            mockMapper.Setup(x => x.Map <RecordTypeDbO, RecordType>(It.IsAny <RecordTypeDbO>()))
            .Returns(TestHelper.CreateRecordType);

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var recordTypeService = new RecordTypeService(recordTypeRepositoryMock.Object, mockMapper.Object, shareService);
            var result            =
                recordTypeService.GetRecordTypeById("-1");
        }