Esempio n. 1
0
        public void ThrowWithInvalidConfigParameter()
        {
            var resource = new PopupResource();
            var contextMock = new Mock<IResourceContext>();

            Assert.Throws<ArgumentNullException>(() => resource.Execute(contextMock.Object, null));
        }
Esempio n. 2
0
        public void NotSupportNonPrivilegedExecution()
        {
            var resource = new PopupResource();
            var contextMock = new Mock<IResourceContext>();

            Assert.Throws<NotSupportedException>(()=>resource.Execute(contextMock.Object));
        }
Esempio n. 3
0
        public void ThrowWithInvalidContextParameter()
        {
            var resource = new PopupResource();
            var configMock = new Mock<IGlimpseConfiguration>();

            Assert.Throws<ArgumentNullException>(() => resource.Execute(null, configMock.Object));
        }
Esempio n. 4
0
        public void RejectInvalidRequestIdParameters(string value, bool hasValue)
        {
            var resource = new PopupResource();
            var contextMock = new Mock<IResourceContext>();
            contextMock.Setup(c => c.Parameters.TryGetValue("requestId", out value)).Returns(hasValue);
            var configMock = new Mock<IGlimpseConfiguration>();

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

            var statusCodeResult = result as StatusCodeResourceResult;

            Assert.NotNull(result);
            Assert.Equal(404, statusCodeResult.StatusCode);
        }
Esempio n. 5
0
        public void ReturnHtmlResourceResult()
        {
            var resource = new PopupResource();
            var contextMock = new Mock<IResourceContext>();
            var guid = Guid.NewGuid();
            string requestId = guid.ToString();
            contextMock.Setup(c => c.Parameters.TryGetValue("requestId", out requestId)).Returns(true);
            var version = "1.X.Y";
            contextMock.Setup(c => c.Parameters.TryGetValue("version", out version)).Returns(true);

            Func<Guid?, string> strategy = (id) => requestId + version;
            var configMock = new Mock<IGlimpseConfiguration>();

            configMock.Setup(c => c.FrameworkProvider.HttpRequestStore.Get(Constants.ClientScriptsStrategy)).Returns(() => strategy);
            var result = resource.Execute(contextMock.Object, configMock.Object);

            var htmlResourceResult = result as HtmlResourceResult;

            Assert.NotNull(result);
            Assert.Contains(requestId, htmlResourceResult.Html);
            Assert.Contains(version, htmlResourceResult.Html);
        }