Skip to content

Commit

Permalink
Rename IStateManager methods to get and set
Browse files Browse the repository at this point in the history
  • Loading branch information
rinrab committed Jan 2, 2024
1 parent 5600c49 commit 86d6714
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions AOVpnManager.Tests/StateManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public void LastConnectionName()

try
{
stateManager.UpdateLastConnectionName("Contosa Vpn");
Assert.AreEqual("Contosa Vpn", stateManager.ReadLastConnectionName());
stateManager.SetLastConnectionName("Contosa Vpn");
Assert.AreEqual("Contosa Vpn", stateManager.GetLastConnectionName());

stateManager.UpdateLastConnectionName("Contosa Always On Vpn");
Assert.AreEqual("Contosa Always On Vpn", stateManager.ReadLastConnectionName());
stateManager.SetLastConnectionName("Contosa Always On Vpn");
Assert.AreEqual("Contosa Always On Vpn", stateManager.GetLastConnectionName());

stateManager.UpdateLastConnectionName(null);
Assert.AreEqual(null, stateManager.ReadLastConnectionName());
stateManager.SetLastConnectionName(null);
Assert.AreEqual(null, stateManager.GetLastConnectionName());

stateManager.UpdateLastConnectionName("Contosa Vpn v2");
Assert.AreEqual("Contosa Vpn v2", stateManager.ReadLastConnectionName());
stateManager.SetLastConnectionName("Contosa Vpn v2");
Assert.AreEqual("Contosa Vpn v2", stateManager.GetLastConnectionName());
}
finally
{
Expand Down
4 changes: 2 additions & 2 deletions AOVpnManager/IStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface IStateManager
{
string ReadLastConnectionName();
void UpdateLastConnectionName(string connectionName);
string GetLastConnectionName();
void SetLastConnectionName(string connectionName);
}
}
8 changes: 4 additions & 4 deletions AOVpnManager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static int Main(string[] args)
try
{
GroupPolicySettings settings = policyProvider.ReadSettings();
string lastConnectionName = stateManager.ReadLastConnectionName();
string lastConnectionName = stateManager.GetLastConnectionName();

using (IVpnManager vpnManager = VpnManager.Create())
{
Expand All @@ -29,7 +29,7 @@ static int Main(string[] args)
{
vpnManager.DeleteVpnConnection(lastConnectionName);
logger.VpnConnectionDeleted(lastConnectionName);
stateManager.UpdateLastConnectionName(null);
stateManager.SetLastConnectionName(null);
}
}
else
Expand All @@ -38,7 +38,7 @@ static int Main(string[] args)
{
vpnManager.DeleteVpnConnection(lastConnectionName);
logger.VpnConnectionDeleted(lastConnectionName);
stateManager.UpdateLastConnectionName(null);
stateManager.SetLastConnectionName(null);
}

VpnConnectionInfo oldConnection = FindVpnConnection(vpnManager, settings.VpnConnectionName);
Expand All @@ -56,7 +56,7 @@ static int Main(string[] args)
logger.VpnConnectionUpdated(settings.VpnConnectionName);
}

stateManager.UpdateLastConnectionName(settings.VpnConnectionName);
stateManager.SetLastConnectionName(settings.VpnConnectionName);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions AOVpnManager/StateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public StateManager(RegistryKey root, string path)
this.path = path;
}

public string ReadLastConnectionName()
public string GetLastConnectionName()
{
using (RegistryKey key = root.OpenSubKey(path))
{
return key?.GetValue<string>(LastConnectionName, null);
}
}

public void UpdateLastConnectionName(string connectionName)
public void SetLastConnectionName(string connectionName)
{
using (RegistryKey key = OpenOrCreateKey())
{
Expand Down

0 comments on commit 86d6714

Please sign in to comment.