public void Init()
        {
            this.mockConfigManager = new Mock<IConfigurationManager<IISConfig>>();
            this.mockConfigManager.Setup(c => c.GetSection(It.IsAny<string>())).Returns(TestData.TestIISConfig.Instance);

            this.mockValidation = new Mock<IConfigValidationService>();
            this.mockValidation.Setup(v => v.IsSatisfiedBy(TestData.TestIISConfig.Instance)).Returns(true);

            this.configService = GivenANewIISConfigurationServiceInstance(this.mockConfigManager, this.mockValidation);
        }
        public void WhenTheIConfigValidationServiceIsSatisfiedByMethodReturnsFalseAnExceptionIsThrown()
        {
            this.mockValidation.Setup(v => v.IsSatisfiedBy(It.IsAny<IISConfig>())).Returns(false);

            Assert.Throws(
                Is.TypeOf<Exception<IISConfigExceptionArgs>>()
                    .And.Message.Contains(TestData.TestIISConfig.Instance.IIsExecutablePath)
                    .And.Message.Contains(TestData.TestIISConfig.Instance.IISConfigFilePath),
                () =>
                {
                    this.configService = new IISConfigurationService(
                        this.mockConfigManager.Object, this.mockValidation.Object);
                });
        }
        public void WhenTheIISConfigHasAnInvalidIIsExecutablePathPropertyAnExceptionIsThrown()
        {
            var localConfig = new IISConfig
                { IIsExecutablePath = "zz:/RubishPath", IISConfigFilePath = "yy:/MoreRubbish" };
            this.mockConfigManager.Setup(c => c.GetSection(It.IsAny<string>())).Returns(localConfig);

            Assert.Throws(
                Is.TypeOf<Exception<IISConfigExceptionArgs>>().And.Message.Contains("zz:/RubishPath"),
                () =>
                    {
                        this.configService = new IISConfigurationService(
                            this.mockConfigManager.Object, this.mockValidation.Object);
                    });
        }
        /// <summary>
        /// Private helper method to create a new IISExpress instance
        /// </summary>
        /// <returns> New instance of IISExpress </returns>
        private static IISExpress GivenANewIISExpressInstance()
        {
            var configManager = new IISConfigurationManager<IISConfig>();
            var validation = new IISConfigValidationService();
            var configuration = new IISConfigurationService(configManager, validation);

            var procManagerService = new ProcessManagementService();

            return new IISExpress(configuration, procManagerService);
        }