コード例 #1
0
        public void Host_ThrowsIfValueNotSet()
        {
            var mock = new Mock <IConfiguration>();

            mock.Setup(x => x.GetSection("SMEIoT")).Returns(_emptyMock.Object);
            var service = new MqttClientConfigService(mock.Object);

            Action act = () => service.GetHost();

            // assert
            var exce = Assert.Throws <InvalidOperationException>(act);

            Assert.Contains("MqttHost", exce.Message);
        }
コード例 #2
0
        public void Host_Returns()
        {
            // arrange
            var mock = new Mock <IConfiguration>();

            mock.Setup(x => x.GetSection("SMEIoT")).Returns(_sectionMock.Object);
            var service = new MqttClientConfigService(mock.Object);

            // act
            var res = service.GetHost();

            // assert
            Assert.Equal("127.0.0.1", res);
        }