public void CallsRequestGateIfWanted()
            {
                var hasBeenCalled = false;
                var mock          = new Mock <IGate>();

                mock.Setup(x => x.CheckRequestGate).Returns(true);
                mock.Setup(x => x.CheckStatisticGate).Returns(false);
                mock.Setup(x => x.RequestGate(It.IsAny <string>(), It.IsAny <HttpRequestBase>())).Returns(() => hasBeenCalled = true);
                var context = MvcTestBase.CreateRequestContext(new Uri("http://localhost"), string.Empty, string.Empty);

                var target = new TestGateMvcAttribute(mock.Object);

                target.OnActionExecuting(context);

                Assert.IsTrue(hasBeenCalled);
            }
            public void NotCallsStatisticsGateIfNotWanted()
            {
                var hasBeenCalled = false;
                var mock          = new Mock <IGate>();

                mock.Setup(x => x.CheckRequestGate).Returns(false);
                mock.Setup(x => x.CheckStatisticGate).Returns(false);
                mock.Setup(x => x.StatisticsGate(It.IsAny <string>(), It.IsAny <ConcurrentDictionary <string, ClientStatistic> >())).Returns(() => hasBeenCalled = true);
                var context = MvcTestBase.CreateRequestContext(new Uri("http://localhost"), string.Empty, string.Empty);

                var target = new TestGateMvcAttribute(mock.Object);

                target.OnActionExecuting(context);

                Assert.IsFalse(hasBeenCalled);

                // call gate to execute the code
                mock.Setup(x => x.CheckStatisticGate).Returns(true);
                target.OnActionExecuting(context);
                Assert.IsTrue(hasBeenCalled);
            }