Example #1
0
        public void ReturnResourceResult()
        {
            var metadata = new GlimpseMetadata();

            var storeMock = new Mock<IReadOnlyPersistenceStore>();
            storeMock.Setup(s => s.GetMetadata()).Returns(metadata);

            var contextMock = new Mock<IResourceContext>();
            contextMock.Setup(c => c.PersistenceStore).Returns(storeMock.Object);
            contextMock.Setup(c => c.Parameters[ResourceParameter.Callback.Name]).Returns("a string");

            var resource = new MetadataResource();

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

            Assert.NotNull(result);
        }
Example #2
0
        public void Return404ResultIfDataIsMissing()
        {
            var storeMock = new Mock<IReadOnlyPersistenceStore>();
            storeMock.Setup(s => s.GetMetadata()).Returns<GlimpseMetadata>(null);

            var contextMock = new Mock<IResourceContext>();
            contextMock.Setup(c => c.PersistenceStore).Returns(storeMock.Object);

            var resource = new MetadataResource();

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

            Assert.NotNull(result);

            var statusCodeResult = result as StatusCodeResourceResult;
            Assert.NotNull(statusCodeResult);
            Assert.Equal(404, statusCodeResult.StatusCode);
        }