public void Single_deserializes_xml_response_into_TReturn_type() { var session = MockRepository.GenerateStub <IQBSessionInternal>(); session.Expect(x => x.ProcessRequest(null)) .IgnoreArguments() .Return(ValidSessionResponseForClassQueries()); var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs"); var @class = daoChild.Single(); Assert.AreEqual("22", @class.ListID, "ListID"); }
public void Single_throws_QBException_when_error_message_in_qb_response() { var response = ValidSessionResponseForClassQueries(); response.Descendants("ClassQueryRs").First().Attribute("statusCode").SetValue("500"); response.Descendants("ClassQueryRs").First().Attribute("statusMessage").SetValue("There was an error in the query"); var session = MockRepository.GenerateStub <IQBSessionInternal>(); session.Expect(x => x.ProcessRequest(null)) .IgnoreArguments() .Return(response); var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs"); var classes = daoChild.Single(); }
public void Single_returns_null_when_nothing_returns() { var noReturnedClasses = ValidSessionResponseForClassQueries(); noReturnedClasses.Descendants("ClassQueryRs").First().RemoveNodes(); var session = MockRepository.GenerateStub <IQBSessionInternal>(); session.Expect(x => x.ProcessRequest(null)) .IgnoreArguments() .Return(noReturnedClasses); var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs"); Assert.IsNull(daoChild.Single()); }
public void Single_clears_xml_message_afterwards() { var expectedMessage = new XElement("ClassQueryRq"); var session = MockRepository.GenerateStub <IQBSessionInternal>(); session.Stub(x => x.ProcessRequest(null)) .IgnoreArguments() .Return(ValidSessionResponseForClassQueries()) .Repeat.Any(); var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs"); daoChild.MaxReturned(20).Single(); daoChild.Single(); var actualMessage = session.GetArgumentsForCallsMadeOn(x => x.ProcessRequest(null))[1][0] as XElement; AssertXmlAreEqual(expectedMessage, actualMessage); }