public void MessagingPublisher_WhenEventHandlerOverPublisherWasNotSet_ExpectExceptionThrown() { MessagingPublisher messagingPublisher = new MessagingPublisher(); messagingPublisher.TransformAndPublishData((data) => { ErrorLog = data; }, "message"); Assert.AreEqual(ExceptionCode.MessagingPublisher_PublisherNotSetOrThreadRacing, ErrorLog); }
public void MessagingPublisher_WhenEventHandlerOverPublisherWasSet_ExpectWorkingFine() { MessagingPublisher messagingPublisher = new MessagingPublisher(); messagingPublisher.DataPublisher += (object sender, string e) => { }; messagingPublisher.TransformAndPublishData((data) => { ErrorLog = data; }, "message"); Assert.AreEqual("", ErrorLog); }
public void MessagingSubscriber_WhenContructorReceivePublisher_ExpectPublisherWillAssignAccordingly() { // Act var messagingPublisher = new MessagingPublisher(); // Arrange var messagingSubscriber = new MessagingSubscriber(messagingPublisher); // Assert Assert.IsNotNull(messagingSubscriber.Publisher); }
protected new void CreateResponseAndLog(HttpActionContext actionContext, HttpStatusCode status, string msg = "") { var errorCode = string.IsNullOrWhiteSpace(msg) ? (status == HttpStatusCode.Forbidden ? "You are not authorized!" : "Please provide credentials!") : msg; actionContext.Response = actionContext.Request.CreateErrorResponse(status, errorCode); _stopwatch.Stop(); if (!LogEnabled) { return; } // TODO - evaluate if this is needed. Maybe it should be refactored to a pure access log but it needs to also record IP, etc. IdentityHelper.LogAction( actionContext.ActionDescriptor.ControllerDescriptor.ControllerName, actionContext.ActionDescriptor.ActionName, false, actionContext.Response.StatusCode.ToString()); MessagingPublisher?.LogExposedAPIAccess(_id, actionContext, _stopwatch.Elapsed, false); }