public void ExposeProcessRequestTest1()
        {
            //Arrange
            var exposeService = MockRepository.GenerateMock <ExposeService>();

            exposeService.Stub(x => x.Process(null)).IgnoreArguments().Return(new ResponseList {
                new UpdateBasketItemResponse {
                    Result = new Basket()
                }
            });

            var factory = MockRepository.GenerateMock <IServiceFactory>();

            factory.Stub(x => x.CreateProxy <ExposeService, ExposeServiceClient>(Arg <bool> .Is.Anything, Arg <ICacheManager> .Is.Anything, Arg <string> .Is.Anything, ref Arg <ExposeServiceClient> .Ref(Is.Anything(), null).Dummy))
            .Return(exposeService);

            // Act
            using (var client = new AccessClient(factory))
            {
                client.RegisterRequest("1", new UpdateBasketItemRequest());
                client.ProcessRequests();

                Basket result;
                client.TryGet("1", out result);

                // Assert
                Assert.IsNotNull(result);
            }
        }
        public void ExceptionWhenProcessingRequestsTest1()
        {
            //Arrange
            var exposeService = MockRepository.GenerateMock <ExposeService>();

            exposeService.Stub(x => x.Process(null)).IgnoreArguments().Throw(new ApplicationException());

            var factory = MockRepository.GenerateMock <IServiceFactory>();

            factory.Stub(x => x.CreateProxy <ExposeService, ExposeServiceClient>(Arg <bool> .Is.Anything, Arg <ICacheManager> .Is.Anything, Arg <string> .Is.Anything, ref Arg <ExposeServiceClient> .Ref(Is.Anything(), null).Dummy))
            .Return(exposeService);

            // Act
            using (var client = new AccessClient(factory))
            {
                client.RegisterRequest("1", new UpdateBasketItemRequest());
                client.ProcessRequests();
            }

            // Assert
            Assert.Fail("Should not get here. ProcessRequest throws exeption.");
        }
        public static IAccessClient GetAccessClient(this System.Web.UI.Page page)
        {
            var client = page.Items["EnfernoStormApiClient"] as IAccessClient;

            if (client != null)
            {
                return(client);
            }

            lock (syncRoot)
            {
                client = page.Items["EnfernoStormApiClient"] as IAccessClient;
                if (client != null)
                {
                    return(client);
                }

                client          = new AccessClient("AccessClient");
                page.Unload    += (o, e) => client.Dispose();
                page.PreRender += (o, e) => client.ProcessRequests(page);
                page.Items["EnfernoStormApiClient"] = client;
            }
            return(client);
        }