diff --git a/Sharp.Augeas.Test/AugeasTests.cs b/Sharp.Augeas.Test/AugeasTests.cs
index 526fb75..3a82049 100644
--- a/Sharp.Augeas.Test/AugeasTests.cs
+++ b/Sharp.Augeas.Test/AugeasTests.cs
@@ -1,9 +1,14 @@
+using System.Text;
+
namespace Sharp.Augeas.Test;
public class AugeasTests
{
private Augeas _augeas;
-
+
+ private const string EXAMPLE_CONF_1 = "/etc/apache2/sites-available/example.com.conf";
+ private const string EXAMPLE_CONF_2 = "/etc/apache2/sites-available/example2.com.conf";
+
public static string RandomString(int length)
{
var random = new Random();
@@ -12,21 +17,21 @@ public class AugeasTests
.Select(s => s[random.Next(s.Length)]).ToArray());
}
-
+
[SetUp]
public void Setup()
{
var rootDir = Environment.CurrentDirectory + "/root";
var lensDir = Environment.CurrentDirectory + "/lens";
_augeas = new Augeas(new AugSettings(rootDir, lensDir));
- _augeas.LoadFile("/etc/apache2/sites-available/example.com.conf");
- _augeas.LoadFile("/etc/apache2/sites-available/example2.com.conf");
+ _augeas.LoadFile(EXAMPLE_CONF_1);
+ _augeas.LoadFile(EXAMPLE_CONF_2);
}
[Test]
public void NoExceptionThrownWhenPrintingVirtualhostTree()
{
- var virtualHostConfig = "/etc/apache2/sites-available/example.com.conf";
+ var virtualHostConfig = EXAMPLE_CONF_1;
_augeas.PrintVirtualHostTree(virtualHostConfig);
Assert.Pass();
}
@@ -34,40 +39,34 @@ public class AugeasTests
[Test]
public void NoExceptionThrownWhenPrintingPreview()
{
- var virtualHostConfig = "/etc/apache2/sites-available/example.com.conf";
- _augeas.PrintPreview(virtualHostConfig);
- Assert.Pass();
-
+ var virtualHostConfig = EXAMPLE_CONF_1;
+ _augeas.PrintPreview(virtualHostConfig);
+ Assert.Pass();
}
[Test]
public void GetPreviewReturnsValid()
{
-
- var preview = _augeas.GetPreview("/files/etc/apache2/sites-available/example.com.conf");
- var stringInvalid = string.IsNullOrEmpty(preview);
- Assert.That(!stringInvalid);
-
+ var preview = _augeas.GetPreview("/files/etc/apache2/sites-available/example.com.conf");
+ var stringInvalid = string.IsNullOrEmpty(preview);
+ Assert.That(!stringInvalid);
}
-
-
+
+
[Test]
public void AfterSettingNodeGetNodeReturnsNewValue()
{
-
var nodePath = $"/files/etc/apache2/sites-available/example.com.conf/VirtualHost/directive[1]/arg";
var newValue = "example.com";
_augeas.SetNode(nodePath, newValue);
var retrieveVal = _augeas.GetNode(nodePath);
Assert.That(retrieveVal == newValue);
}
-
-
-
+
+
[Test]
public void SettingNodeAndSave()
{
-
var nodePath = $"/files/etc/apache2/sites-available/example.com.conf/VirtualHost/directive[1]/arg";
var newValue = RandomString(10);
_augeas.SetNode(nodePath, newValue);
@@ -79,36 +78,43 @@ public class AugeasTests
var retrieveVal = _augeas.GetNode(nodePath);
Assert.That(retrieveVal == newValue);
}
-
-
+
+
[Test]
public void InsertNode()
{
-
var nodePath = $"/files/etc/apache2/sites-available/example.com.conf/VirtualHost/directive[3]";
_augeas.InsertNode(nodePath, "Test");
var node = _augeas.GetNode(nodePath);
Assert.Pass();
}
-
-
-
+
+
[Test]
public void MatchReturnsTwoSites()
{
var sites = _augeas.Match("/files/etc/apache2/sites-available/*");
Assert.That(sites.Length == 2);
}
-
-
+
+
+
+ [Test]
+ public void MatchCanReturnMultipleDirectives()
+ {
+ var nodePath = $"/files/etc/apache2/sites-available/example.com.conf/VirtualHost/directive[7]/*";
+ var sites = _augeas.Match(nodePath);
+ Assert.That(sites.Length > 0);
+ }
+
[Test]
public void GetTreeVirtualHostReturnsDictionaryWithKeys()
{
- var path = "/etc/apache2/sites-available/example.com.conf";
+ var path = EXAMPLE_CONF_1;
var tree = _augeas.GetVirtualHostTree(path);
- Assert.That(tree.Count > 0);
+ Assert.That(tree.Count > 0);
}
}
\ No newline at end of file
diff --git a/Sharp.Augeas/Sharp.Augeas.csproj b/Sharp.Augeas/Sharp.Augeas.csproj
index 9676111..ddd724c 100644
--- a/Sharp.Augeas/Sharp.Augeas.csproj
+++ b/Sharp.Augeas/Sharp.Augeas.csproj
@@ -15,4 +15,9 @@
root\%(RecursiveDir)\%(Filename)%(Extension)
+
+
+ PreserveNewest
+
+
diff --git a/Sharp.Augeas/VirtualHost/Directive.cs b/Sharp.Augeas/VirtualHost/Directive.cs
index 6e00548..c97f8e7 100644
--- a/Sharp.Augeas/VirtualHost/Directive.cs
+++ b/Sharp.Augeas/VirtualHost/Directive.cs
@@ -1,7 +1,7 @@
namespace Sharp.Augeas;
-public class Directive : Node where T: Node
+public class Directive : Node
{
public string Value;
- public List>> Arguments;
+ public List Arguments;
}
\ No newline at end of file
diff --git a/Sharp.Augeas/VirtualHost/VirtualHost.cs b/Sharp.Augeas/VirtualHost/VirtualHost.cs
index 5b57c78..538cf63 100644
--- a/Sharp.Augeas/VirtualHost/VirtualHost.cs
+++ b/Sharp.Augeas/VirtualHost/VirtualHost.cs
@@ -1,6 +1,6 @@
namespace Sharp.Augeas
{
- public class VirtualHost
+ public class VirtualHost : Node
{
public List> Directives;
public List> Arguments;