コード例 #1
0
        public void ThrowExceptionIfSecretNotValid(string invalidSecret)
        {
            // [Setup]
            // setup webhost using appsettings with specific path
            var appSettingsValidator = new AppSettingsValidator();
            var appSettings          = new AppSettings();

            appSettings.JwtSecret = invalidSecret;

            // [Verify]
            // we expect to have a appsettings invalid exception
            Assert.Throws <InvalidAppSettingsException>(() =>
            {
                appSettingsValidator.EnsureValid(appSettings);
            });

            // [Teardown]
            // nothing to tear down
        }
コード例 #2
0
        public void ThrowExceptionIfProductTypeNotValid(Type productType)
        {
            // [Setup]
            // setup webhost using appsettings with specific path
            var appSettingsValidator = new AppSettingsValidator();
            var appSettings          = new AppSettings();

            appSettings.ProductType = productType;

            // [Verify]
            // we expect to have a appsettings invalid exception
            var exception = Assert.Throws <InvalidAppSettingsException>(() =>
            {
                appSettingsValidator.EnsureValid(appSettings);
            });

            Assert.Equal(nameof(appSettings.ProductType), exception.PropertyName);

            // [Teardown]
            // nothing to tear down
        }