Beispiel #1
0
        public void TestInheritance(
            bool?enabledInSolution,
            bool enabledInProject,
            bool?enableOptionInProject,
            string testInput,
            ImplicitNullabilityAppliesTo expectedAppliesTo)
        {
            void ChangeSolutionSettings(IContextBoundSettingsStore settingsStore) =>
            settingsStore.SetValue((ImplicitNullabilitySettings x) => x.Enabled, enabledInSolution ?? TestRandom.NextBool());

            void ChangeProjectSettings(IContextBoundSettingsStore settingsStore)
            {
                settingsStore.SetValue((ImplicitNullabilitySettings x) => x.Enabled, enabledInProject);

                enableOptionInProject = enableOptionInProject ?? TestRandom.NextBool();
                settingsStore.SetValue((ImplicitNullabilitySettings x) => x.EnableInputParameters, enableOptionInProject);
                settingsStore.SetValue((ImplicitNullabilitySettings x) => x.EnableRefParameters, enableOptionInProject);
                settingsStore.SetValue((ImplicitNullabilitySettings x) => x.EnableOutParametersAndResult, enableOptionInProject);
                settingsStore.SetValue((ImplicitNullabilitySettings x) => x.EnableFields, enableOptionInProject);
                settingsStore.SetValue((ImplicitNullabilitySettings x) => x.EnableProperties, enableOptionInProject);
            }

            //

            var configuration = GetImplicitNullabilityConfigurationFor(testInput, ChangeSolutionSettings, ChangeProjectSettings);

            //

            Assert.That(configuration.AppliesTo, Is.EqualTo(expectedAppliesTo));
        }