public void HotspotConfiguration_GivenDifferentFileName_WillNotFinishInitialization() { var sut = new HotspotConfiguration(ruleLoaderMock.Object); Initialize(sut, "FooBarSonarLint.xml"); ruleLoaderMock.Verify(r => r.GetEnabledRules(It.IsAny <string>()), Times.Never); }
public void HotspotConfiguration_WhenInitializeIsSecondTimeWithNonSonarLint_DoesNotUpdateEnabledRules() { var sut = new HotspotConfiguration(ruleLoaderMock.Object); // act Initialize(sut, FirstSonarLintFile); Initialize(sut, "Foo.xml"); // assert ruleLoaderMock.Verify(r => r.GetEnabledRules(It.IsAny <string>()), Times.Once); ruleLoaderMock.Verify(r => r.GetEnabledRules(FirstSonarLintFile), Times.Once); }
public void HotspotConfiguration_WhenInitializeIsCalledWithDifferentSonarLintPaths_UpdatesEnabledRules() { var sut = new HotspotConfiguration(ruleLoaderMock.Object); // act Initialize(sut, FirstSonarLintFile); // assert IsTrue(sut.IsEnabled(FirstRuleId)); IsFalse(sut.IsEnabled(SecondRuleId)); // act Initialize(sut, SecondSonarLintFile); // assert IsFalse(sut.IsEnabled(FirstRuleId)); IsTrue(sut.IsEnabled(SecondRuleId)); ruleLoaderMock.Verify(r => r.GetEnabledRules(FirstSonarLintFile), Times.Once); ruleLoaderMock.Verify(r => r.GetEnabledRules(SecondSonarLintFile), Times.Once); }
private static void Initialize(HotspotConfiguration sut, string path) => sut.Initialize(new AnalyzerOptions(GetAdditionalFiles(path)));
public void HotspotConfiguration_WhenIsInitializedWithNull_ThrowsException() { var sut = new HotspotConfiguration(ruleLoaderMock.Object); sut.Invoking(x => x.Initialize(null)).Should().Throw <NullReferenceException>(); }
public void HotspotConfiguration_WhenIsEnabledWithoutInitialized_ThrowException() { var sut = new HotspotConfiguration(ruleLoaderMock.Object); sut.Invoking(x => x.IsEnabled("")).Should().Throw <InvalidOperationException>().WithMessage("Call Initialize() before calling IsEnabled()."); }