Esempio n. 1
0
        public void BeforeRequest_AddsHostParameter()
        {
            //Setup
            var newSite = new TargetSiteMock("127.0.0.1")
            {
                SetHost = "www.google.com"
            };
            var settings = new APISettings()
            {
                DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite
            };
            var request = new GetRequestStub(settings);

            //Mock crap
            var restReq = new Mock <IRestRequest>();

            restReq.Setup(x => x.AddHeader("Host", "www.google.com"));

            var restClient = new Mock <IRestClient>();

            request.Request = restReq.Object;
            request.Client  = restClient.Object;

            //Assert
            request.RunBeforeGet();
            restReq.VerifyAll();
        }
Esempio n. 2
0
        public void BeforeRequest_RaisesBeforeRequestEvent()
        {
            //Setup
            var newSite = new TargetSiteMock("127.0.0.1")
            {
                SetHost = "www.google.com"
            };
            var settings = new APISettings()
            {
                DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite
            };
            var request = new GetRequestStub(settings);

            //Mock crap
            var restReq    = new Mock <IRestRequest>();
            var restClient = new Mock <IRestClient>();

            restClient.Setup(x => x.BaseUrl).Returns("https://127.0.0.1/Exammple");
            request.Request = restReq.Object;
            request.Client  = restClient.Object;

            //Assert
            request.OnBeforeRequest += (HandleBeforeRequest);
            request.RunBeforeGet();
            Assert.AreEqual(true, _HasEventFired);
            request.OnBeforeRequest -= (HandleBeforeRequest);
        }
Esempio n. 3
0
        public void BeforeRequest_SetsDevKey_AndDomain_AndCobrand_AndSiteID_AndTimeout()
        {
            //Setup
            var request = new GetRequestStub(_Settings);

            //Mock crap
            var restReq = new Mock <IRestRequest>();

            restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey"));
            restReq.Setup(x => x.AddParameter("CoBrand", "this is a cobrand"));
            restReq.Setup(x => x.AddParameter("SiteID", "this is a siteid"));
            restReq.SetupSet(x => x.Timeout = 12345);

            var restClient = new Mock <IRestClient>();

            request.Request = restReq.Object;
            request.Client  = restClient.Object;

            //Assert
            request.RunBeforeGet();
            restReq.VerifyAll();
        }