public void GetMonitor_ReturnsExpectedValue() { var functionId = "FunctionId"; var eventHubName = "EventHubName"; var consumerGroup = "ConsumerGroup"; var host = new EventProcessorHost(consumerGroup, "Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=abc123=", eventHubName, new EventProcessorOptions(), 3, null); var consumerClientMock = new Mock <IEventHubConsumerClient>(); consumerClientMock.SetupGet(c => c.ConsumerGroup).Returns(consumerGroup); consumerClientMock.SetupGet(c => c.EventHubName).Returns(eventHubName); var listener = new EventHubListener( functionId, Mock.Of <ITriggeredFunctionExecutor>(), host, false, consumerClientMock.Object, Mock.Of <BlobsCheckpointStore>(), new EventHubOptions(), Mock.Of <LoggerFactory>()); IScaleMonitor scaleMonitor = listener.GetMonitor(); Assert.AreEqual(typeof(EventHubsScaleMonitor), scaleMonitor.GetType()); Assert.AreEqual($"{functionId}-EventHubTrigger-{eventHubName}-{consumerGroup}".ToLower(), scaleMonitor.Descriptor.Id); var scaleMonitor2 = listener.GetMonitor(); Assert.AreSame(scaleMonitor, scaleMonitor2); }
public void GetMonitor_ReturnsExpectedValue() { var functionId = "FunctionId"; var eventHubName = "EventHubName"; var consumerGroup = "ConsumerGroup"; var storageUri = new Uri("https://eventhubsteststorageaccount.blob.core.windows.net/"); var testLogger = new TestLogger("Test"); var listener = new EventHubListener( functionId, eventHubName, consumerGroup, "Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=abc123=", "DefaultEndpointsProtocol=https;AccountName=EventHubScaleMonitorFakeTestAccount;AccountKey=ABCDEFG;EndpointSuffix=core.windows.net", new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict).Object, null, false, new EventHubOptions(), testLogger, new Mock <CloudBlobContainer>(MockBehavior.Strict, new Uri("https://eventhubsteststorageaccount.blob.core.windows.net/azure-webjobs-eventhub")).Object); IScaleMonitor scaleMonitor = listener.GetMonitor(); Assert.Equal(typeof(EventHubsScaleMonitor), scaleMonitor.GetType()); Assert.Equal($"{functionId}-EventHubTrigger-{eventHubName}-{consumerGroup}".ToLower(), scaleMonitor.Descriptor.Id); var scaleMonitor2 = listener.GetMonitor(); Assert.Same(scaleMonitor, scaleMonitor2); }