public void List_deserializes_xml_response_into_TReturns_type() { var session = MockRepository.GenerateStub <IQBSessionInternal>(); session.Expect(x => x.ProcessRequest(null)) .IgnoreArguments() .Return(ValidSessionResponseForClassQueries()); var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs"); var classes = daoChild.List(); Assert.AreEqual(2, classes.Count, "Count"); Assert.AreEqual("22", classes[0].ListID, "First ListID"); Assert.AreEqual(4, classes[1].Sublevel, "Second Sublevel"); }
public void List_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.List(); }
public void List_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).List(); daoChild.List(); var actualMessage = session.GetArgumentsForCallsMadeOn(x => x.ProcessRequest(null))[1][0] as XElement; AssertXmlAreEqual(expectedMessage, actualMessage); }