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)); }); }
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"); }); }
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"); }); }
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"); }); }
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"); }); }