コード例 #1
0
        public void LoadConfiguration_No_Configuration_Model()
        {
            var mockRepository = new Mock <IOptions <Domain.Infrastructure.ApplicationConfiguration.ConfigurationData> >();

            mockRepository.Setup(options => options.Value).Returns((Domain.Infrastructure.ApplicationConfiguration.ConfigurationData)null);

            var repository        = new ConfigurationDataRespository(mockRepository.Object);
            var entityModelResult = repository.LoadConfigurationData();

            Assert.NotNull(entityModelResult);
            Assert.Equal(string.Empty, entityModelResult.Something);

            Assert.NotNull(entityModelResult.ServiceEndpoints);
            Assert.Equal(0, entityModelResult.ServiceEndpoints.Count);
        }
コード例 #2
0
        public void LoadConfiguration_No_Something()
        {
            var expectedConfigurationModel =
                new Domain.Infrastructure.ApplicationConfiguration.ConfigurationData
            {
                ServiceEndpoints = new List <Domain.Infrastructure.ApplicationConfiguration.ServiceEndpointDetail>(),
                Something        = null
            };

            var mockRepository = new Mock <IOptions <Domain.Infrastructure.ApplicationConfiguration.ConfigurationData> >();

            mockRepository.Setup(options => options.Value).Returns(expectedConfigurationModel);

            var repository        = new ConfigurationDataRespository(mockRepository.Object);
            var entityModelResult = repository.LoadConfigurationData();

            Assert.NotNull(entityModelResult);
            Assert.NotNull(entityModelResult.Something);
            Assert.Equal(string.Empty, entityModelResult.Something);
        }
コード例 #3
0
        public void LoadConfiguration_Copies_Over_Endpoints()
        {
            var expectedServiceEndpoints = new List <Domain.Infrastructure.ApplicationConfiguration.ServiceEndpointDetail>
            {
                new Domain.Infrastructure.ApplicationConfiguration.ServiceEndpointDetail()
                {
                    KeyName = "firstKey", Url = "first url"
                },
                new Domain.Infrastructure.ApplicationConfiguration.ServiceEndpointDetail()
                {
                    KeyName = "secondKey", Url = "second url"
                }
            };

            var expectedConfigurationModel =
                new Domain.Infrastructure.ApplicationConfiguration.ConfigurationData
            {
                ServiceEndpoints = expectedServiceEndpoints,
                Something        = "does not matter for this test"
            };

            var mockRepository = new Mock <IOptions <Domain.Infrastructure.ApplicationConfiguration.ConfigurationData> >();

            mockRepository.Setup(options => options.Value).Returns(expectedConfigurationModel);

            var repository        = new ConfigurationDataRespository(mockRepository.Object);
            var entityModelResult = repository.LoadConfigurationData();

            Assert.NotNull(entityModelResult);

            Assert.NotNull(entityModelResult.ServiceEndpoints);
            Assert.Equal(expectedConfigurationModel.ServiceEndpoints.Count, entityModelResult.ServiceEndpoints.Count);

            // Can modularize this if need arises
            CheckEndpoint(expectedServiceEndpoints[0], entityModelResult);
            CheckEndpoint(expectedServiceEndpoints[1], entityModelResult);
        }