public ResponseModels <Client> GetData()
        {
            var result  = new ResponseModels <Client>();
            var clients = ResourcesHandler.Load <Client>(AddressValues.CLIENTS, TableNameValues.CLIENTS);

            if (!clients.Any())
            {
                result.NotValidResponse(MessageValues.CLIENTS_REPOSITORY_EMPTY);

                return(result);
            }

            result.IsValid = true;
            result.Models  = clients.Select(c => (Client) new Client().InjectFrom(c));

            return(result);
        }
        public ResponseModels <Policy> GetData()
        {
            var result   = new ResponseModels <Policy>();
            var policies = ResourcesHandler.Load <Policy>(AddressValues.POLICIES, TableNameValues.POLICIES);

            if (!policies.Any())
            {
                result.NotValidResponse(MessageValues.POLICIES_REPOSITORY_EMPTY);

                return(result);
            }

            result.IsValid = true;
            result.Models  = policies.Select(c => (Policy) new Policy().InjectFrom(c));

            return(result);
        }
Example #3
0
        public void LoadPolicies_ResponsePoliciesData_IfAddressAndTableNameExists()
        {
            var result = ResourcesHandler.Load <Policy>(AddressValues.POLICIES, TableNameValues.POLICIES);

            Assert.IsNotEmpty(result);
        }
Example #4
0
        public void LoadClients_ResponseClientsData_IfAddressAndTableNameExists()
        {
            var result = ResourcesHandler.Load <Client>(AddressValues.CLIENTS, TableNameValues.CLIENTS);

            Assert.IsNotEmpty(result);
        }
Example #5
0
 public void Load_NullReferenceException_IfTableNameNotExists()
 {
     Assert.Throws <NullReferenceException>(() => ResourcesHandler.Load <Client>(AddressValues.CLIENTS, TABLE_NAME_NOT_EXIST));
     Assert.Throws <NullReferenceException>(() => ResourcesHandler.Load <Policy>(AddressValues.POLICIES, TABLE_NAME_NOT_EXIST));
 }
Example #6
0
 public void Load_WebException_IfAddressNotExists()
 {
     Assert.Throws <WebException>(() => ResourcesHandler.Load <Client>(ADDRESS_NOT_EXIST, TABLE_NAME_NOT_EXIST));
     Assert.Throws <WebException>(() => ResourcesHandler.Load <Policy>(ADDRESS_NOT_EXIST, TABLE_NAME_NOT_EXIST));
 }
Example #7
0
 public void Load_ArgumentNullException_IfAnyParametersIsNullOrEmpty(string address, string tableName)
 {
     Assert.Throws <ArgumentNullException>(() => ResourcesHandler.Load <Client>(address, tableName));
     Assert.Throws <ArgumentNullException>(() => ResourcesHandler.Load <Policy>(address, tableName));
 }