Ejemplo n.º 1
0
        public void Check_config_no_address_does_not_throw()
        {
            var config = new ViewRangerConfigurationSection
            {
                ApplicationKey = new ApplicationKeyElement
                {
                    Key = Guid.NewGuid().ToString()
                }
            };

            Assert.DoesNotThrow(() => this.CreateClient(config));
        }
Ejemplo n.º 2
0
        public void Check_config_no_key_throws()
        {
            var config = new ViewRangerConfigurationSection
            {
                BaseAddress = new AddressElement
                {
                    Url = Guid.NewGuid().ToString()
                }
            };

            var ex = Assert.Throws <ConfigurationErrorsException>(() => this.CreateClient(config));
        }
Ejemplo n.º 3
0
        public void Check_applicationKey_is_set()
        {
            var key    = Guid.NewGuid().ToString();
            var config = new ViewRangerConfigurationSection
            {
                ApplicationKey = new ApplicationKeyElement
                {
                    Key = key
                }
            };
            var client = this.CreateClient(config);

            this.AssertPrivateVariable(client, "_applicationKey", key);
        }
Ejemplo n.º 4
0
        public void Check_config_no_address_defaults()
        {
            var config = new ViewRangerConfigurationSection
            {
                ApplicationKey = new ApplicationKeyElement
                {
                    Key = Guid.NewGuid().ToString()
                }
            };

            var client = this.CreateClient(config);

            this.AssertPrivateVariable(client, "_baseAddress", ViewRangerClient.DefaultApiBaseAddress);
        }
Ejemplo n.º 5
0
        public void Check_baseAddress_is_set()
        {
            var address = Guid.NewGuid().ToString();
            var config  = new ViewRangerConfigurationSection
            {
                ApplicationKey = new ApplicationKeyElement
                {
                    Key = Guid.NewGuid().ToString()
                },
                BaseAddress = new AddressElement
                {
                    Url = address
                }
            };
            var client = this.CreateClient(config);

            this.AssertPrivateVariable(client, "_baseAddress", address);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a ViewRanger client which will load the given configuration section
 /// </summary>
 /// <param name="config">The config section to load</param>
 public ViewRangerClient CreateClient(ViewRangerConfigurationSection config)
 {
     try
     {
         var client = new Mock <TestingViewRangerClient>();
         client.Setup(x => x.PublicConfigurationLoad()).Returns(config);
         client.CallBase = true;
         return(client.Object);
     }
     catch (TargetInvocationException tiEx) // if we get errors unwrap them from the Mock/Reflection exception
     {
         throw tiEx.InnerException;
     }
     catch (Exception)
     {
         throw; // anything else throw it!
     }
 }