public void AcquireTopParameter(string parameterName, string parameterValue, bool parameterValueIsInt, int expectedResult)
        {
            var resource = new HistoryResource();

            var storeMock = new Mock<IReadOnlyPersistenceStore>();
            var contextMock = new Mock<IResourceContext>();
            string output = parameterValue;
            contextMock.Setup(c => c.Parameters.TryGetValue(parameterName, out output)).Returns(parameterValueIsInt);
            contextMock.Setup(c => c.PersistenceStore).Returns(storeMock.Object);

            resource.Execute(contextMock.Object);

            storeMock.Verify(s=>s.GetTop(expectedResult));
        }
        public void ReturnJsonResourceResultWithData()
        {
            var resource = new HistoryResource();

            var storeMock = new Mock<IReadOnlyPersistenceStore>();
            storeMock.Setup(s => s.GetTop(It.IsAny<int>())).Returns(Enumerable.Empty<GlimpseRequest>());
            var contextMock = new Mock<IResourceContext>();
            string output = "25";
            contextMock.Setup(c => c.Parameters.TryGetValue("top", out output)).Returns(true);
            contextMock.Setup(c => c.PersistenceStore).Returns(storeMock.Object);

            var result = resource.Execute(contextMock.Object);

            var jsonResourceResult = result as JsonResourceResult;

            Assert.NotNull(jsonResourceResult);
        }
        public void Return404StatusCodeWithoutData()
        {
            var resource = new HistoryResource();

            var storeMock = new Mock<IReadOnlyPersistenceStore>();
            storeMock.Setup(s => s.GetTop(It.IsAny<int>())).Returns<IEnumerable<GlimpseRequest>>(null);
            var contextMock = new Mock<IResourceContext>();
            string output = "25";
            contextMock.Setup(c => c.Parameters.TryGetValue("top", out output)).Returns(true);
            contextMock.Setup(c => c.PersistenceStore).Returns(storeMock.Object);

            var result = resource.Execute(contextMock.Object);

            var statusCodeResult = result as StatusCodeResourceResult;

            Assert.NotNull(statusCodeResult);
            Assert.Equal(404, statusCodeResult.StatusCode);
        }
        public void ThrowExceptionWithNullContext()
        {
            var resource = new HistoryResource();

            Assert.Throws<ArgumentNullException>(()=>resource.Execute(null));
        }