GetReceiver() public méthode

public GetReceiver ( string receiverName ) : IWebHookReceiver
receiverName string
Résultat IWebHookReceiver
        public void GetReceiver_Returns_Null_IfNoReceivers()
        {
            // Arrange
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            IWebHookReceiver actual = manager.GetReceiver(MockReceiverName);

            // Assert
            Assert.Null(actual);
        }
        public void GetReceiver_Returns_Null_IfNoReceivers()
        {
            // Arrange
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            IWebHookReceiver actual = manager.GetReceiver(MockReceiverName);

            // Assert
            Assert.Null(actual);
        }
        public void GetReceiver_Returns_ReceiverWithSingleName(string receiverName)
        {
            // Arrange
            _receivers.Add(_receiver);
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            IWebHookReceiver actual = manager.GetReceiver(receiverName);

            // Assert
            Assert.Same(_receiver, actual);
        }
        public void GetReceiver_Returns_ReceiverWithSingleName(string receiverName)
        {
            // Arrange
            _receivers.Add(_receiver);
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            IWebHookReceiver actual = manager.GetReceiver(receiverName);

            // Assert
            Assert.Same(_receiver, actual);
        }
        public void GetReceiver_Returns_ReceiverWithMultipleNames(string name1, string name2, string name3)
        {
            // Arrange
            MockReceiver multiReceiver = new MockReceiver(name1, name2, name3);
            _receivers.Add(multiReceiver);
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            IWebHookReceiver actual = manager.GetReceiver(MockReceiverName);

            // Assert
            Assert.Same(multiReceiver, actual);
        }
        public void GetReceiver_Returns_Null_IfUnknownReceiver()
        {
            // Arrange
            MockReceiver multiReceiver = new MockReceiver();
            _receivers.Add(multiReceiver);
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            IWebHookReceiver actual = manager.GetReceiver("unknown");

            // Assert
            Assert.Null(actual);
        }
        public void GetReceiver_Returns_Null_IfUnknownReceiver()
        {
            // Arrange
            MockReceiver multiReceiver = new MockReceiver();

            _receivers.Add(multiReceiver);
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            IWebHookReceiver actual = manager.GetReceiver("unknown");

            // Assert
            Assert.Null(actual);
        }
        public void GetReceiver_Throws_IfDuplicateSingleNameReceivers()
        {
            // Arrange
            _receivers.Add(_receiver);
            _receivers.Add(_receiver);
            _receivers.Add(_receiver);
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            InvalidOperationException ex = Assert.Throws<InvalidOperationException>(() => manager.GetReceiver(MockReceiverName));

            // Assert
            Assert.Contains("Multiple types were found that match the WebHook receiver named 'MockReceiver'. This can happen if multiple receivers are defined with the same name but different casing which is not supported. The request for 'MockReceiver' has found the following matching receivers:", ex.Message);
        }
        public void GetReceiver_Throws_IfDuplicateSingleNameReceivers()
        {
            // Arrange
            _receivers.Add(_receiver);
            _receivers.Add(_receiver);
            _receivers.Add(_receiver);
            IWebHookReceiverManager manager = new WebHookReceiverManager(_receivers, _loggerMock.Object);

            // Act
            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => manager.GetReceiver(MockReceiverName));

            // Assert
            Assert.Contains("Multiple types were found that match the WebHook receiver named 'MockReceiver'. This can happen if multiple receivers are defined with the same name but different casing which is not supported. The request for 'MockReceiver' has found the following matching receivers:", ex.Message);
        }