public void InternalServiceRequestHandler_ProcessRequest_WhenNullExecutingUser_ExpectException() { //------------Setup for test-------------------------- EsbExecuteRequest eer = new EsbExecuteRequest { ServiceName = "Ping" }; var internalServiceRequestHandler = new InternalServiceRequestHandler { ExecutingUser = null }; //------------Execute Test--------------------------- internalServiceRequestHandler.ProcessRequest(eer, Guid.Empty, Guid.Empty, Guid.NewGuid().ToString()); }
public void InternalServiceRequestHandler_ProcessRequest_WhenMalformedConnectionId_ExpectException() { //------------Setup for test-------------------------- Mock<IPrincipal> principle = new Mock<IPrincipal>(); principle.Setup(p => p.Identity.Name).Returns("FakeUser"); EsbExecuteRequest eer = new EsbExecuteRequest { ServiceName = "Ping" }; var internalServiceRequestHandler = new InternalServiceRequestHandler { ExecutingUser = principle.Object }; //------------Execute Test--------------------------- internalServiceRequestHandler.ProcessRequest(eer, Guid.Empty, Guid.Empty, "1"); }
public void InternalServiceRequestHandler_ProcessRequest_WhenNullExecutingUserInFirstOverload_ExpectException() { //------------Setup for test-------------------------- Mock<ICommunicationContext> ctx = new Mock<ICommunicationContext>(); NameValueCollection boundVariables = new NameValueCollection { { "servicename", "ping" }, { "instanceid", "" }, { "bookmark", "" } }; NameValueCollection queryString = new NameValueCollection { { GlobalConstants.DLID, Guid.Empty.ToString() }, { "wid", Guid.Empty.ToString() } }; ctx.Setup(c => c.Request.BoundVariables).Returns(boundVariables); ctx.Setup(c => c.Request.QueryString).Returns(queryString); ctx.Setup(c => c.Request.Uri).Returns(new Uri("http://localhost")); var internalServiceRequestHandler = new InternalServiceRequestHandler { ExecutingUser = null }; //------------Execute Test--------------------------- internalServiceRequestHandler.ProcessRequest(ctx.Object); }
public void InternalServiceRequestHandler_ProcessRequest_WhenExecutingUserInFirstOverload_ExpectThreadHasCorrectUserContext() { //------------Setup for test-------------------------- Mock<IPrincipal> principle = new Mock<IPrincipal>(); principle.Setup(p => p.Identity.Name).Returns("FakeUser"); principle.Setup(p => p.Identity.Name).Verifiable(); Mock<ICommunicationContext> ctx = new Mock<ICommunicationContext>(); NameValueCollection boundVariables = new NameValueCollection { { "servicename", "ping" }, { "instanceid", "" }, { "bookmark", "" } }; NameValueCollection queryString = new NameValueCollection { { GlobalConstants.DLID, Guid.Empty.ToString() }, { "wid", Guid.Empty.ToString() } }; ctx.Setup(c => c.Request.BoundVariables).Returns(boundVariables); ctx.Setup(c => c.Request.QueryString).Returns(queryString); ctx.Setup(c => c.Request.Uri).Returns(new Uri("http://localhost")); var internalServiceRequestHandler = new InternalServiceRequestHandler { ExecutingUser = principle.Object }; //------------Execute Test--------------------------- internalServiceRequestHandler.ProcessRequest(ctx.Object); //------------Assert Results------------------------- principle.Verify(p => p.Identity.Name, Times.AtLeast(1)); }