Esempio n. 1
0
        public UserIdentityDto AuthenticateIndividualCustomer(string identity, string password)
        {
            var repository = new SIRepository();
            var customerRepository = new SICustomerRepository();
            var userRepository = new SIUserRepository();
            var hashProvider = new SIHashProvider();

            IDtoCreator<UserIdentity, UserIdentityDto> identityCreator = new UserIdentityDtoCreator();
            hashProvider.HashString = (x) => x;

            customerRepository.GetCustomerByIdentityString = (x) => _customers.SingleOrDefault(c => c.Identification == x);

            //act
            UserServices userServices = new UserServices(customerRepository, repository,null,hashProvider, identityCreator);
            UserIdentityDto result = userServices.AuthenticateUser(identity, password);

            //assert
            PexAssert.Case(identity == _customers[0].Identification && password == _customers[0].Password)
                    .Implies(() => result.Email == _customers[0].Email);
            return result;
        }
Esempio n. 2
0
        public UserIdentityDto AuthenticateIndividualCustomer(string identity, string password)
        {
            var repository         = new SIRepository();
            var customerRepository = new SICustomerRepository();
            var userRepository     = new SIUserRepository();
            var hashProvider       = new SIHashProvider();

            IDtoCreator <UserIdentity, UserIdentityDto> identityCreator = new UserIdentityDtoCreator();

            hashProvider.HashString = (x) => x;

            customerRepository.GetCustomerByIdentityString = (x) => _customers.SingleOrDefault(c => c.Identification == x);

            //act
            UserServices    userServices = new UserServices(customerRepository, repository, null, hashProvider, identityCreator);
            UserIdentityDto result       = userServices.AuthenticateUser(identity, password);

            //assert
            PexAssert.Case(identity == _customers[0].Identification && password == _customers[0].Password)
            .Implies(() => result.Email == _customers[0].Email);
            return(result);
        }