コード例 #1
0
ファイル: CacheHandlerTests.cs プロジェクト: Narinyir/caching
 public void WcfService_CachedResponse()
 {
     Container.Register<WcfServiceStub>(Lifetime.Transient);
     SharedContext.ResetServiceCallCount(ServiceName.WcfStub);
     var stub = Container.Get<WcfServiceStub>();
     Assert.IsNotNull(stub);
     var request = new GetMemberDetailsRequest();
     var id1 = RandomDataGenerator.GetRandomString(10);
     request.MemberId = id1;            
     var response = stub.GetMemberDetails(request);
     Assert.AreEqual(1, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
     Assert.AreEqual("MEMBER-" + id1, response);
     //call again, ensure cached:
     response = stub.GetMemberDetails(request);
     Assert.AreEqual(1, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
     Assert.AreEqual("MEMBER-" + id1, response);
     //call with new request, ensure not cached:
     var id2 = RandomDataGenerator.GetRandomString(10);
     request.MemberId = id2;
     response = stub.GetMemberDetails(request);
     Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
     Assert.AreEqual("MEMBER-" + id2, response);
     //call with req 1:
     request.MemberId = id1;
     response = stub.GetMemberDetails(request);
     Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
     Assert.AreEqual("MEMBER-" + id1, response);
     //call with req 2:
     request.MemberId = id2;
     response = stub.GetMemberDetails(request);
     Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
     Assert.AreEqual("MEMBER-" + id2, response);
 }
コード例 #2
0
        public void WcfService_CachedResponse()
        {
            Container.Register <WcfServiceStub>(Lifetime.Transient);
            SharedContext.ResetServiceCallCount(ServiceName.WcfStub);
            var stub = Container.Get <WcfServiceStub>();

            Assert.IsNotNull(stub);
            var request = new GetMemberDetailsRequest();
            var id1     = RandomDataGenerator.GetRandomString(10);

            request.MemberId = id1;
            var response = stub.GetMemberDetails(request);

            Assert.AreEqual(1, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
            Assert.AreEqual("MEMBER-" + id1, response);
            //call again, ensure cached:
            response = stub.GetMemberDetails(request);
            Assert.AreEqual(1, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
            Assert.AreEqual("MEMBER-" + id1, response);
            //call with new request, ensure not cached:
            var id2 = RandomDataGenerator.GetRandomString(10);

            request.MemberId = id2;
            response         = stub.GetMemberDetails(request);
            Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
            Assert.AreEqual("MEMBER-" + id2, response);
            //call with req 1:
            request.MemberId = id1;
            response         = stub.GetMemberDetails(request);
            Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
            Assert.AreEqual("MEMBER-" + id1, response);
            //call with req 2:
            request.MemberId = id2;
            response         = stub.GetMemberDetails(request);
            Assert.AreEqual(2, SharedContext.GetServiceCallCount(ServiceName.WcfStub));
            Assert.AreEqual("MEMBER-" + id2, response);
        }
コード例 #3
0
 public virtual string GetMemberDetails(GetMemberDetailsRequest request)
 {
     SharedContext.IncrementServiceCallCount(CacheHandlerTests.ServiceName.WcfStub);
     return(string.Format("MEMBER-{0}", request.MemberId));
 }
コード例 #4
0
ファイル: CacheHandlerTests.cs プロジェクト: Narinyir/caching
 public virtual string GetMemberDetails(GetMemberDetailsRequest request)
 {
     SharedContext.IncrementServiceCallCount(CacheHandlerTests.ServiceName.WcfStub);
     return string.Format("MEMBER-{0}", request.MemberId);
 }