Ejemplo n.º 1
0
        public void Ctor_ValidArgs()
        {
            var userSettings = new UserSettings();
            var testSubject  = new CFamilyBindingConfigFile(userSettings);

            testSubject.UserSettings.Equals(userSettings);
        }
        public void Ctor_ValidArgs()
        {
            var settings    = new RulesSettings();
            var testSubject = new CFamilyBindingConfigFile(settings);

            testSubject.RuleSettings.Equals(settings);
        }
Ejemplo n.º 3
0
        public void Save_SettingsAreSerializedAndSaved()
        {
            // Arrange
            var settings = new UserSettings
            {
                Rules = new Dictionary <string, RuleConfig>
                {
                    { "key", new RuleConfig
                      {
                          Level      = RuleLevel.On,
                          Severity   = IssueSeverity.Minor,
                          Parameters = new Dictionary <string, string>
                          {
                              { "p1", "p2" }
                          }
                      } }
                }
            };

            string actualPath = null;
            string actualText = null;

            var fileSystemMock = new Mock <IFile>();

            fileSystemMock.Setup(x => x.WriteAllText(It.IsAny <string>(), It.IsAny <string>()))
            .Callback <string, string>((p, t) => { actualPath = p; actualText = t; });

            var testSubject = new CFamilyBindingConfigFile(settings, fileSystemMock.Object);

            // Act
            testSubject.Save("c:\\full\\path\\file.txt");

            // Assert
            actualPath.Should().Be("c:\\full\\path\\file.txt");
            actualText.Should().Be(@"{
  ""sonarlint.rules"": {
    ""key"": {
      ""level"": ""On"",
      ""parameters"": {
        ""p1"": ""p2""
      },
      ""severity"": ""Minor""
    }
  }
}");
        }