public void Initialize_Success() { // arrange var transmitterMock = new Mock <ITelemetryAttachmentTransmitter>(); transmitterMock.Setup(t => t.Enqueue(It.IsAny <AttachmentDescriptor>())); var transmitter = transmitterMock.Object; var transmitters = new[] { transmitter }; var initializer = new AttachmentTransmissionInitializer(transmitters); // act initializer.Initialize(); // assert var attachment = new ExceptionAttachment { Id = AttachmentId.NewId(), Name = "Foo", Value = new byte[] { 1, 2, 3 } }; AttachmentDispatcher.Instance.Dispatch(attachment); transmitterMock.Verify( t => t.Enqueue(It.IsAny <AttachmentDescriptor>()), Times.Once()); AttachmentDispatcher.Instance.Detach(transmitter); }
public void GetTypeName_Attachment_Success() { // arrange IAttachment attachment = new ExceptionAttachment(); // act string typeName = attachment.GetTypeName(); // assert Assert.Equal("Exception", typeName); }
public void InternalServerErrorOccurred(Exception exception) { if (IsEnabled()) { AttachmentId attachmentId = AttachmentId.NewId(); ExceptionAttachment attachment = AttachmentFactory.Create(attachmentId, nameof(exception), exception); AttachmentDispatcher.Instance.Dispatch(attachment); InternalServerErrorOccurred(Application.Id, ActivityStack.Id, attachmentId); } }
public void OnQueryError(Exception exception) { if (IsEnabled()) { AttachmentId attachmentId = AttachmentId.NewId(); ExceptionAttachment attachment = AttachmentFactory .Create(attachmentId, nameof(exception), exception); AttachmentDispatcher.Instance.Dispatch(attachment); OnQueryError( Application.Id, ActivityStack.Id, attachmentId, exception.Message); } }
public void Dispatch_Exception_PayloadValueNull() { // arrange ExceptionAttachment attachment = null; AttachmentId correlationId = AttachmentId.NewId(); string payloadName = "Name-567"; Exception payloadValue = null; // act Action verify = () => attachment = AttachmentFactory .Create(correlationId, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); Assert.Null(attachment); }
public void Create_Exception_PayloadNameNull() { // arrange ExceptionAttachment attachment = null; AttachmentId correlationId = AttachmentId.NewId(); string payloadName = null; Exception payloadValue = new ArgumentNullException("Value-426"); // act Action verify = () => attachment = AttachmentFactory .Create(correlationId, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); Assert.Null(attachment); }
public void Dispatch_Exception_Success() { // arrange ExceptionAttachment attachment = null; AttachmentId correlationId = AttachmentId.NewId(); string payloadName = "Name-848"; Exception payloadValue = new ArgumentNullException("Value-848"); // act Action verify = () => attachment = AttachmentFactory .Create(correlationId, payloadName, payloadValue); // assert Assert.Null(Record.Exception(verify)); Assert.NotNull(attachment); Assert.IsType <ExceptionAttachment>(attachment); }