示例#1
0
        public void NotSupportNonPrivilegedExecution()
        {
            var resource = new PopupResource();
            var contextMock = new Mock<IResourceContext>();

            Assert.Throws<NotSupportedException>(()=>resource.Execute(contextMock.Object));
        }
示例#2
0
        public void ThrowWithInvalidConfigParameter()
        {
            var resource = new PopupResource();
            var contextMock = new Mock<IResourceContext>();

            Assert.Throws<ArgumentNullException>(() => resource.Execute(contextMock.Object, null));
        }
示例#3
0
        public void ThrowWithInvalidContextParameter()
        {
            var resource = new PopupResource();
            var configMock = new Mock<IGlimpseConfiguration>();

            Assert.Throws<ArgumentNullException>(() => resource.Execute(null, configMock.Object));
        }
示例#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);
        }
示例#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);
        }
示例#6
0
        public void ContainRequiredVersionParameter()
        {
            var resource = new PopupResource();

            Assert.Contains("version", resource.Parameters.Where(p => p.IsRequired).Select(p => p.Name));
        }
示例#7
0
        public void BeNamedProperly()
        {
            var resource = new PopupResource();

            Assert.Equal("glimpse_popup", resource.Name);
        }
示例#8
0
        public void ContainOptionalHashParameter()
        {
            var resource = new PopupResource();

            Assert.Contains("hash", resource.Parameters.Select(p => p.Name));
        }