Skip to content

Commit

Permalink
Fix a bug where adding a new LinkedCommand required a restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ilic committed Apr 9, 2019
1 parent c307c32 commit 808a60a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions LicenseHeaderManager.Test/LicenseHeaderManager.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<Compile Include="CommentParserTests.cs" />
<Compile Include="LinkedFileFilterTest.cs" />
<Compile Include="LinkedFileHandlerTest.cs" />
<Compile Include="OptionsPageTest.cs" />
<Compile Include="ProjectItemInspectionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
36 changes: 36 additions & 0 deletions LicenseHeaderManager.Test/OptionsPageTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using LicenseHeaderManager.Options;
using NUnit.Framework;

namespace LicenseHeaderManager.Test
{
[TestFixture]
public class OptionsPageTest
{
[Test]
public void TestLinkedCommandsChangedCalledWhenNewLinkedCommandSavedWithExistingLinkedCommands ()
{
var optionsPage = new OptionsPage();
var wasCalled = false;
optionsPage.LinkedCommandsChanged += (sender, args) => wasCalled = true;
const string emptySerializedLinkedCommands = "1*System.String*<LinkedCommands/>";
optionsPage.LinkedCommandsSerialized = emptySerializedLinkedCommands;

optionsPage.LinkedCommands.Add (new LinkedCommand());

Assert.That (wasCalled, Is.True);
}

[Test]
public void TestLinkedCommandsChangedCalledWhenNewLinkedCommandSavedWithDefaultLinkedCommands ()
{
var optionsPage = new OptionsPage();
var wasCalled = false;
optionsPage.LinkedCommandsChanged += (sender, args) => wasCalled = true;

optionsPage.LinkedCommands.Add (new LinkedCommand());

Assert.That (wasCalled, Is.True);
}
}
}
4 changes: 2 additions & 2 deletions LicenseHeaderManager/Options/OptionsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public ObservableCollection<LinkedCommand> LinkedCommands
// ReSharper disable once UnusedMember.Global
public string LinkedCommandsSerialized
{
get { return _linkedCommandConverter.ToXml (_linkedCommands); }
set { _linkedCommands = new ObservableCollection<LinkedCommand> (_linkedCommandConverter.FromXml (value)); }
get { return _linkedCommandConverter.ToXml (LinkedCommands); }
set { LinkedCommands = new ObservableCollection<LinkedCommand> (_linkedCommandConverter.FromXml (value)); }
}

private void OnLinkedCommandsChanged (object sender, NotifyCollectionChangedEventArgs e)
Expand Down

0 comments on commit 808a60a

Please sign in to comment.