public void BeforeWrappedMethod_ReturnsNoOp_IfTheCurrentSegmentIsLeaf() { Mock.Arrange(() => _wrapperMap.Get(Arg.IsAny <InstrumentedMethodInfo>())).Returns(new TrackedWrapper(_transactionRequiredWrapper)); var transaction = Mock.Create <ITransaction>(); var segment = Mock.Create <ISegment>(); Mock.Arrange(() => transaction.IsValid).Returns(true); Mock.Arrange(() => transaction.CurrentSegment).Returns(segment); Mock.Arrange(() => segment.IsLeaf).Returns(true); Mock.Arrange(() => _agent.CurrentTransaction).Returns(transaction); var type = typeof(Class_WrapperService); const string methodName = "MyMethod"; const string tracerFactoryName = "MyTracer"; var target = new object(); var arguments = new object[0]; using (var logging = new TestUtilities.Logging()) { var afterWrappedMethod = _wrapperService.BeforeWrappedMethod(type, methodName, string.Empty, target, arguments, tracerFactoryName, null, EmptyTracerArgs, 0); Assert.AreEqual(Delegates.NoOp, afterWrappedMethod, "AfterWrappedMethod was not the NoOp delegate."); Assert.False(logging.HasMessage("skipping method")); } }
public void verify_UpdateTree_handles_null_StackInfo_argument() { using (var logging = new TestUtilities.Logging()) { ThreadProfilingBucket bucket = new ThreadProfilingBucket(new MockThreadProfilingService()); bucket.UpdateTree(null); Assert.IsTrue(logging.HasMessageBeginingWith("fids passed to UpdateTree is null")); } }
public void exception_thrown_from_subscriber_writes_error_log_message() { using (var logger = new TestUtilities.Logging()) using (new EventSubscription <object>(_ => { throw new Exception(); })) { EventBus <object> .Publish(new object()); Assert.AreEqual(1, logger.ErrorCount); } }
public void ExecuteOnce_LogsExceptions() { using (var logging = new TestUtilities.Logging()) { _scheduler.ExecuteOnce(() => { throw new Exception(); }, TimeSpan.FromMilliseconds(1)); AssertEventuallyTrue(() => logging.ErrorCount == 1); } }
public void CallVendorApi_LogsException() { using (var logging = new TestUtilities.Logging()) { var requestor = new VendorHttpApiRequestor(); var response = requestor.CallVendorApi(BogusUri, "bogus"); Assert.That(response, Is.Null); Assert.True(logging.HasMessageThatContains("CallVendorApi")); } }
public void TestInvalidServiceAttribute() { using (var logging = new TestUtilities.Logging()) { // this should load with an error in the event log ConfigurationLoader.InitializeFromXml( "<configuration xmlns=\"urn:newrelic-config\">" + "<service bogus=\"true\" licenseKey=\"dude\"/>" + "<application><name>My App</name></application>" + "</configuration>"); var errorMessage = Type.GetType("Mono.Runtime") == null ? "An error occurred parsing newrelic.config - The 'bogus' attribute is not declared." : "An error occurred parsing newrelic.config - XmlSchema error: Attribute declaration was not found for bogus"; Assert.IsTrue(logging.HasMessageThatContains(errorMessage)); } }
public void SetUp() { _dataTransportService = Mock.Create <IDataTransportService>(); _logging = new TestUtilities.Logging(); _disposables = new DisposableCollection { _logging }; EventBus <ConfigurationUpdatedEvent> .Publish(new ConfigurationUpdatedEvent(CreateMockConfiguration(), ConfigurationUpdateSource.Unknown)); _timestamp = new DateTime(2018, 1, 1, 1, 0, 0); _path = "WebTransaction/ASP/post.aspx"; _message = "The Error Message"; _exceptionClassName = "System.MyErrorClassName"; _stackTrace = CreateStackTrace(); _guid = "123"; _attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f)); }
public void SetUp() { _logger = new TestUtilities.Logging(); }