Ejemplo n.º 1
0
        public void LoginException()
        {
            With.Mocks(
                delegate
            {
                IWebRequestHelper mockedRequestHelper;
                string success;
                using (Mocker.Current.Record())
                {
                    mockedRequestHelper = Mocker.Current.StrictMock <IWebRequestHelper>();
                    RhinoHelper.AddLoginExceptionExpectation(mockedRequestHelper, new ArgumentException("A generic exception"));
                }

                MainProgram testThread = new MainProgram(_config);
                Assert.Throws <ArgumentException>(() => testThread.LoginHttp(mockedRequestHelper));
            });
        }
Ejemplo n.º 2
0
        public void ServiceRequest()
        {
            With.Mocks(
                delegate
            {
                IWebServiceHelper mockedServiceHelper;
                using (Mocker.Current.Record())
                {
                    mockedServiceHelper = Mocker.Current.StrictMock <IWebServiceHelper>();
                    RhinoHelper.AddServiceRequestExpectation(mockedServiceHelper);
                }

                MainProgram testThread = new MainProgram(_config);
                var returnString       = testThread.MakeWebServiceCall(mockedServiceHelper);
                Assert.That(returnString == "This Was Mocked");
            });
        }
Ejemplo n.º 3
0
        public void LoginAndTest()
        {
            With.Mocks(
                delegate
            {
                IWebRequestHelper mockedRequestHelper;
                string success;
                using (Mocker.Current.Record())
                {
                    mockedRequestHelper = Mocker.Current.StrictMock <IWebRequestHelper>();
                    RhinoHelper.AddLoginExpectation(mockedRequestHelper, _config);
                    RhinoHelper.AddTestExpectation(mockedRequestHelper);
                }

                MainProgram testThread = new MainProgram(_config);
                success = testThread.LoginAndTest(mockedRequestHelper);
                Assert.That(success == "success");
            });
        }
Ejemplo n.º 4
0
        public void HttpRequest()
        {
            With.Mocks(
                delegate
            {
                HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(new Uri("http://www.myserver.com"));
                IWebRequestHelper mockedRequestHelper;
                string request  = "This is a request";
                string response = "This was Mocked";
                using (Mocker.Current.Record())
                {
                    mockedRequestHelper = Mocker.Current.StrictMock <IWebRequestHelper>();
                    RhinoHelper.AddHttpRequestExpectation(mockedRequestHelper, httpRequest, request, response);
                }

                MainProgram testThread = new MainProgram(_config);
                var returnString       = testThread.MakeWebRequestCall(mockedRequestHelper, httpRequest, request);
                Assert.That(returnString == "This was Mocked");
            });
        }
Ejemplo n.º 5
0
        public void Search()
        {
            With.Mocks(
                delegate
            {
                IWebRequestHelper mockedRequestHelper;
                string success;
                string licenseNumber    = "1234";
                string expectedResponse = "1234";
                using (Mocker.Current.Record())
                {
                    mockedRequestHelper = Mocker.Current.StrictMock <IWebRequestHelper>();
                    RhinoHelper.AddSearchExpectation(mockedRequestHelper, licenseNumber, expectedResponse);
                }

                MainProgram testThread = new MainProgram(_config);
                success = testThread.Search(mockedRequestHelper, licenseNumber);
                Assert.That(success == "success");
            });
        }