Beispiel #1
0
        public void Does_vary_cache_by_UserSession()
        {
            ServerCacheOnly.Count = 0;
            var request = new ServerCacheUser {
                Id = 3, Value = "foo"
            };

            var response = Config.ListeningOn.CombineWith(request.ToGetUrl())
                           .GetJsonFromUrl(requestFilter: req => req.AddHeader("X-ss-id", "1"))
                           .FromJson <ServerCacheUser>();

            Assert.That(ServerCacheUser.Count, Is.EqualTo(1));
            AssertEquals(response, request);

            response = Config.ListeningOn.CombineWith(request.ToGetUrl())
                       .GetJsonFromUrl(requestFilter: req => req.AddHeader("X-ss-id", "1"))
                       .FromJson <ServerCacheUser>();

            Assert.That(ServerCacheUser.Count, Is.EqualTo(1));
            AssertEquals(response, request);

            response = Config.ListeningOn.CombineWith(request.ToGetUrl())
                       .GetJsonFromUrl(requestFilter: req => req.AddHeader("X-ss-id", "2"))
                       .FromJson <ServerCacheUser>();

            Assert.That(ServerCacheUser.Count, Is.EqualTo(2));
            AssertEquals(response, request);
        }
Beispiel #2
0
 public object Any(ServerCacheUser request)
 {
     Interlocked.Increment(ref ServerCacheUser.Count);
     return(request);
 }