Example #1
0
        public void CTORWithParameter_ShoulInstanciate_WhenCalled()
        {
            var sut = new AzureCognitiveArgs(SubscriptionKey: "SubscriptionKey", Endpoint: "Endpoint");

            Assert.Equal("SubscriptionKey", sut.SubscriptionKey);
            Assert.Equal("Endpoint", sut.Endpoint);
        }
        /// <summary>
        /// Logger for debuging purposes and azure subscription information for the Azure Cognitive services.
        /// </summary>
        /// <param name="iLogger"></param>
        /// <param name="SubscriptionConfig"></param>
        public AzureCognitiveAgent(ILogger iLogger, AzureCognitiveArgs SubscriptionConfig)
        {
            this.iLogger = iLogger ??
                           throw new LoggedException(new ArgumentNullException($"{nameof(iLogger)} @ CTOR in AzureCognitiveAgent"));

            this.cognitiveServiceConfig = SubscriptionConfig ??
                                          throw new LoggedException(new ArgumentNullException($"{nameof(SubscriptionConfig)} @ CTOR in AzureCognitiveAgent"));
        }
        public void CTOR_ThrowsLoggedNullException_WhenAzureCognitiveArgsIsNull()
        {
            //ARRANGE
            var mockILogger = TestHelper.MockILogger();

            LoggedException.Logger = mockILogger.Object;
            AzureCognitiveArgs AzArg = null;

            //ACT & ASSERT
            Assert.Throws <LoggedException>(() => new AzureCognitiveAgent(mockILogger.Object, AzArg));
            mockILogger.Verify(x => x.Error(It.IsAny <ArgumentNullException>(), It.IsAny <string>()), Times.Once);
        }