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); }
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); }
public virtual string GetMemberDetails(GetMemberDetailsRequest request) { SharedContext.IncrementServiceCallCount(CacheHandlerTests.ServiceName.WcfStub); return(string.Format("MEMBER-{0}", request.MemberId)); }
public virtual string GetMemberDetails(GetMemberDetailsRequest request) { SharedContext.IncrementServiceCallCount(CacheHandlerTests.ServiceName.WcfStub); return string.Format("MEMBER-{0}", request.MemberId); }