public void NotSupportNonPrivilegedExecution() { var resource = new PopupResource(); var contextMock = new Mock<IResourceContext>(); Assert.Throws<NotSupportedException>(()=>resource.Execute(contextMock.Object)); }
public void ThrowWithInvalidConfigParameter() { var resource = new PopupResource(); var contextMock = new Mock<IResourceContext>(); Assert.Throws<ArgumentNullException>(() => resource.Execute(contextMock.Object, null)); }
public void ThrowWithInvalidContextParameter() { var resource = new PopupResource(); var configMock = new Mock<IGlimpseConfiguration>(); Assert.Throws<ArgumentNullException>(() => resource.Execute(null, configMock.Object)); }
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); }
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); }
public void ContainRequiredVersionParameter() { var resource = new PopupResource(); Assert.Contains("version", resource.Parameters.Where(p => p.IsRequired).Select(p => p.Name)); }
public void BeNamedProperly() { var resource = new PopupResource(); Assert.Equal("glimpse_popup", resource.Name); }
public void ContainOptionalHashParameter() { var resource = new PopupResource(); Assert.Contains("hash", resource.Parameters.Select(p => p.Name)); }