public void XmlService_CachedResponse()
 {
     Container.Register<XmlServiceStub>(Lifetime.Transient);
     SharedContext.ResetServiceCallCount(ServiceName.XmlStub);
     var stub = Container.Get<XmlServiceStub>();
     Assert.IsNotNull(stub);
     var request = new GetGroupIdForQuoteRequest();
     var occ1 = RandomDataGenerator.GetRandomString(10);
     request.OccupationCode = occ1;            
     var response = stub.GetGroupIdForQuote(request);
     Assert.AreEqual(1, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
     Assert.AreEqual("GROUP-" + occ1, response);
     //call again, ensure cached:
     response = stub.GetGroupIdForQuote(request);
     Assert.AreEqual(1, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
     Assert.AreEqual("GROUP-" + occ1, response);
     //call with new request, ensure not cached:
     var occ2 = RandomDataGenerator.GetRandomString(10);
     request.OccupationCode = occ2;          
     response = stub.GetGroupIdForQuote(request);
     Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
     Assert.AreEqual("GROUP-" + occ2, response);
     //call with req 1:
     request.OccupationCode = occ1;
     response = stub.GetGroupIdForQuote(request);
     Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
     Assert.AreEqual("GROUP-" + occ1, response);
     //call with req 2:
     request.OccupationCode = occ2;
     response = stub.GetGroupIdForQuote(request);
     Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
     Assert.AreEqual("GROUP-" + occ2, response);
 }
        public void XmlService_CachedResponse()
        {
            Container.Register <XmlServiceStub>(Lifetime.Transient);
            SharedContext.ResetServiceCallCount(ServiceName.XmlStub);
            var stub = Container.Get <XmlServiceStub>();

            Assert.IsNotNull(stub);
            var request = new GetGroupIdForQuoteRequest();
            var occ1    = RandomDataGenerator.GetRandomString(10);

            request.OccupationCode = occ1;
            var response = stub.GetGroupIdForQuote(request);

            Assert.AreEqual(1, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
            Assert.AreEqual("GROUP-" + occ1, response);
            //call again, ensure cached:
            response = stub.GetGroupIdForQuote(request);
            Assert.AreEqual(1, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
            Assert.AreEqual("GROUP-" + occ1, response);
            //call with new request, ensure not cached:
            var occ2 = RandomDataGenerator.GetRandomString(10);

            request.OccupationCode = occ2;
            response = stub.GetGroupIdForQuote(request);
            Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
            Assert.AreEqual("GROUP-" + occ2, response);
            //call with req 1:
            request.OccupationCode = occ1;
            response = stub.GetGroupIdForQuote(request);
            Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
            Assert.AreEqual("GROUP-" + occ1, response);
            //call with req 2:
            request.OccupationCode = occ2;
            response = stub.GetGroupIdForQuote(request);
            Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.XmlStub));
            Assert.AreEqual("GROUP-" + occ2, response);
        }
 public virtual string GetGroupIdForQuote(GetGroupIdForQuoteRequest request)
 {
     SharedContext.IncrementServiceCallCount(CacheHandlerTests.ServiceName.XmlStub);
     return(string.Format("GROUP-{0}", request.OccupationCode));
 }
 public virtual string GetGroupIdForQuote(GetGroupIdForQuoteRequest request)
 {
     SharedContext.IncrementServiceCallCount(CacheHandlerTests.ServiceName.XmlStub);
     return string.Format("GROUP-{0}", request.OccupationCode);
 }