public void UserSettingsAreCombinedWithDefaultSettings() { var inspectionMock = new Mock <IInspection>(); inspectionMock.Setup(inspection => inspection.Name).Returns("Foo"); var inspectionProviderMock = new Mock <IInspectionProvider>(); inspectionProviderMock.Setup(provider => provider.Inspections).Returns(new[] { inspectionMock.Object }); var userSetting = new CodeInspectionSetting("Foo", CodeInspectionType.CodeQualityIssues); var userSettings = new CodeInspectionSettings { CodeInspections = new HashSet <CodeInspectionSetting>(new[] { userSetting }) }; var persisterMock = new Mock <IPersistanceService <CodeInspectionSettings> >(); persisterMock.Setup(persister => persister.Load(It.IsAny <CodeInspectionSettings>(), null)).Returns(userSettings); var configProvider = new CodeInspectionConfigProvider(persisterMock.Object, inspectionProviderMock.Object); var settings = configProvider.Create().CodeInspections; var defaultSettings = configProvider.CreateDefaults().CodeInspections; Assert.Contains(userSetting, settings.ToArray()); Assert.IsTrue(defaultSettings.All(s => settings.Contains(s))); }
public void SettingsForFoundInspectionsAreAddedToDefaultSettings() { var inspectionMock = new Mock <IInspection>(); inspectionMock.Setup(inspection => inspection.Name).Returns(inspectionMock.Object.GetType().FullName); var inspectionProviderMock = new Mock <IInspectionProvider>(); inspectionProviderMock.Setup(provider => provider.Inspections).Returns(new[] { inspectionMock.Object }); var configProvider = new CodeInspectionConfigProvider(null, inspectionProviderMock.Object); var defaults = configProvider.CreateDefaults(); Assert.NotNull(defaults.GetSetting(inspectionMock.Object.GetType())); }
public void UserSettingsAreNotDuplicatedWithDefaultSettings() { var inspectionMock = new Mock <IInspection>(); inspectionMock.Setup(inspection => inspection.Name).Returns("Foo"); var inspectionProviderMock = new Mock <IInspectionProvider>(); inspectionProviderMock.Setup(provider => provider.Inspections).Returns(new[] { inspectionMock.Object }); var userSetting = new CodeInspectionSetting(inspectionMock.Object.Name, inspectionMock.Object.InspectionType); var userSettings = new CodeInspectionSettings { CodeInspections = new HashSet <CodeInspectionSetting>(new[] { userSetting }) }; var persisterMock = new Mock <IPersistanceService <CodeInspectionSettings> >(); persisterMock.Setup(persister => persister.Load(It.IsAny <CodeInspectionSettings>(), null)).Returns(userSettings); var configProvider = new CodeInspectionConfigProvider(persisterMock.Object, inspectionProviderMock.Object); var settings = configProvider.Create().CodeInspections; Assert.AreEqual(configProvider.CreateDefaults().CodeInspections.Count, settings.Count); }