예제 #1
0
        public void Iterate_clears_xml_message_when_iteration_is_complete()
        {
            var expected = new XElement("ClassQueryRq",
                                        new XAttribute("iterator", "Start"),
                                        new XAttribute("iteratorID", 123),
                                        new XElement("MaxReturned", 20));
            var response = ValidSessionResponseForIteratedClassQueries();

            response.Descendants("ClassQueryRs").First().Attribute("iteratorRemainingCount").SetValue("0");

            var session = MockRepository.GenerateStub <IQBSessionInternal>();

            session.Stub(x => x.ProcessRequest(null))
            .IgnoreArguments()
            .Return(response)
            .Repeat.Any();

            var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs");

            daoChild.MaxReturned(20).AccountListID("55").Iterate();
            daoChild.MaxReturned(20).Iterate();

            var actual = session.GetArgumentsForCallsMadeOn(x => x.ProcessRequest(null))[1][0] as XElement;

            AssertXmlAreEqual(expected, actual);
        }
예제 #2
0
        public void Iterate_does_not_clear_xml_message_when_there_are_still_iterations_left()
        {
            var expected = new XElement("ClassQueryRq",
                                        new XAttribute("iterator", "Continue"),
                                        new XAttribute("iteratorID", 123),
                                        new XElement("MaxReturned", 20));

            var session = MockRepository.GenerateStub <IQBSessionInternal>();

            session.Stub(x => x.ProcessRequest(null))
            .IgnoreArguments()
            .Return(ValidSessionResponseForIteratedClassQueries())
            .Repeat.Any();

            var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs");

            daoChild.MaxReturned(20).Iterate();
            //This should still have the MaxReturned XElement set since we are not
            //at the end of the iteration
            daoChild.Iterate();

            var actual = session.GetArgumentsForCallsMadeOn(x => x.ProcessRequest(null))[1][0] as XElement;

            AssertXmlAreEqual(expected, actual);
        }
예제 #3
0
        public void Iterate_gets_iteratorID_from_response_and_sets_it_on_the_request()
        {
            var expected = new XElement("ClassQueryRq",
                                        new XAttribute("iterator", "Continue"),
                                        new XAttribute("iteratorID", 123),
                                        new XElement("MaxReturned", 20));

            var session = MockRepository.GenerateStub <IQBSessionInternal>();

            session.Stub(x => x.ProcessRequest(null))
            .IgnoreArguments()
            .Return(ValidSessionResponseForIteratedClassQueries())
            .Repeat.Any();

            var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs");

            daoChild.MaxReturned(20).Iterate();
            daoChild.MaxReturned(20).Iterate();

            var actual = session.GetArgumentsForCallsMadeOn(x => x.ProcessRequest(null))[1][0] as XElement;

            AssertXmlAreEqual(expected, actual);
        }
예제 #4
0
        public void Iterate_sets_IteratorRemainingCount()
        {
            var session = MockRepository.GenerateStub <IQBSessionInternal>();

            session.Stub(x => x.ProcessRequest(null))
            .IgnoreArguments()
            .Return(ValidSessionResponseForIteratedClassQueries())
            .Repeat.Any();

            var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs");

            daoChild.MaxReturned(20).Iterate();

            Assert.AreEqual(2000, daoChild.IteratorRemainingCount);
        }
예제 #5
0
        public void Iterate_throws_QBException_when_error_message_in_qb_response()
        {
            var response = ValidSessionResponseForIteratedClassQueries();

            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.MaxReturned(20).Iterate();
        }
예제 #6
0
        public void Iterate_deserializes_xml_response_into_TReturn_type()
        {
            var session = MockRepository.GenerateStub <IQBSessionInternal>();

            session.Stub(x => x.ProcessRequest(null))
            .IgnoreArguments()
            .Return(ValidSessionResponseForIteratedClassQueries())
            .Repeat.Any();

            var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs");
            var classes  = daoChild.MaxReturned(20).Iterate();

            Assert.AreEqual(2, classes.Count, "Count");
            Assert.AreEqual("22", classes[0].ListID, "First ListID");
            Assert.AreEqual(4, classes[1].Sublevel, "Second Sublevel");
        }
예제 #7
0
        public void List_sends_qbxml_message_to_session()
        {
            var expectedMessage = new XElement("ClassQueryRq",
                                               new XElement("MaxReturned", 20));

            var session = MockRepository.GenerateStub <IQBSessionInternal>();

            session.Stub(x => x.ProcessRequest(null))
            .IgnoreArguments()
            .Return(ValidSessionResponseForClassQueries());

            var daoChild = new QueryBaseChild(session, "ClassQueryRq", "ClassQueryRs");

            daoChild.MaxReturned(20).List();

            var actualMessage = session.GetArgumentsForCallsMadeOn(x => x.ProcessRequest(null)).First()[0] as XElement;

            AssertXmlAreEqual(expectedMessage, actualMessage);
        }
예제 #8
0
        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);
        }