Skip to content

Commit

Permalink
Merge pull request rpetz#6 from totpero/master
Browse files Browse the repository at this point in the history
code refactory, fix tests...
  • Loading branch information
Robert Petz authored Jul 12, 2017
2 parents 1906d83 + a96057b commit d9b6beb
Show file tree
Hide file tree
Showing 55 changed files with 144 additions and 156 deletions.
1 change: 1 addition & 0 deletions SharpNetSH.Test/HTTP/AddActionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using Ignite.SharpNetSH.Test.Spike;
using Ignite.SharpNetSH.HTTP;
using Ignite.SharpNetSH.HTTP.Enums;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ignite.SharpNetSH.Test.HTTP
Expand Down
2 changes: 1 addition & 1 deletion SharpNetSH.Test/HTTP/DeleteActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Ignite.SharpNetSH.Test.Spike;
using Ignite.SharpNetSH.HTTP;
using Ignite.SharpNetSH.HTTP.Enums;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ignite.SharpNetSH.Test.HTTP
Expand Down
4 changes: 2 additions & 2 deletions SharpNetSH.Test/Spike/StringHarness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class StringHarness : IExecutionHarness
{
private String _value;

public String Value { get { return _value; } }
public String Value => _value;

public IEnumerable<String> Execute(string action, out int exitCode)
public IEnumerable<String> Execute(string action, out int exitCode)
{
_value = action;
exitCode = 0;
Expand Down
2 changes: 1 addition & 1 deletion SharpNetSH.Test/WLAN/ShowActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Ignite.SharpNetSH.Test.Spike;
using Ignite.SharpNetSH.WLAN;
using Ignite.SharpNetSH.WLAN.Enums;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ignite.SharpNetSH.Test.WLAN
Expand Down
4 changes: 2 additions & 2 deletions SharpNetSH.Test/wlan/AddActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Ignite.SharpNetSH.WLAN;
using Ignite.SharpNetSH.Test.Spike;
using Ignite.SharpNetSH.Test.Spike;
using Ignite.SharpNetSH.WLAN.Enums;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ignite.SharpNetSH.Test.wlan
Expand Down
5 changes: 2 additions & 3 deletions SharpNetSH.Test/wlan/DeleteActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Ignite.SharpNetSH.Test.Spike;
using Ignite.SharpNetSH.Test.Spike;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ignite.SharpNetSH.WLAN;
using Ignite.SharpNetSH.WLAN.Enums;

namespace Ignite.SharpNetSH.Test.wlan
{
Expand Down
19 changes: 9 additions & 10 deletions SharpNetSH.Test/wlan/SetActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Ignite.SharpNetSH.WLAN;
using Ignite.SharpNetSH.Test.Spike;
using Ignite.SharpNetSH.Test.Spike;
using Ignite.SharpNetSH.WLAN.Enums;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ignite.SharpNetSH.Test.wlan
Expand Down Expand Up @@ -35,10 +34,10 @@ public void VerifyBlockedNetworkOutput()
{
var harness = new StringHarness();
new NetSH(harness).Wlan.Set.BlockedNetwork(Display.Show);
Assert.AreEqual("netsh wlan set blockednetworks display=show", harness.Value);
Assert.AreEqual("netsh wlan set blockednetwork display=show", harness.Value);

new NetSH(harness).Wlan.Set.BlockedNetwork(Display.Hide);
Assert.AreEqual("netsh wlan set blockednetworks display=hide", harness.Value);
Assert.AreEqual("netsh wlan set blockednetwork display=hide", harness.Value);
}

[TestMethod]
Expand Down Expand Up @@ -85,23 +84,23 @@ public void VerifyProfileOrderOutput()
{
var harness = new StringHarness();
new NetSH(harness).Wlan.Set.ProfileOrder("\"profile1\"", "\"Wireless Network Connection\"", 1);
Assert.AreEqual("set profileorder name=\"profile1\" interface=\"Wireless Network Connection\" priority=1", harness.Value);
Assert.AreEqual("netsh wlan set profileorder name=\"profile1\" interface=\"Wireless Network Connection\" priority=1", harness.Value);

new NetSH(harness).Wlan.Set.ProfileOrder("\"profile1\"", "\"Wireless Network Connection\"", 5);
Assert.AreEqual("set profileorder name=\"profile two\" interface=\"Wireless Network Connection\" priority=5", harness.Value);
new NetSH(harness).Wlan.Set.ProfileOrder("\"profile2\"", "\"Wireless Network Connection\"", 5);
Assert.AreEqual("netsh wlan set profileorder name=\"profile2\" interface=\"Wireless Network Connection\" priority=5", harness.Value);
}

[TestMethod]
public void VerifyProfileParameterOutput()
{
var harness = new StringHarness();

/*
var tests = new[]
{
new object[] {"Profile1", "interfacename", "ssid1", ConnectionType.Ibss, null, null, false, Authentication.Wpa2, Encryption.Wep, KeyType.Passphrase, null, null, false, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
new object[] {"Profile1", null, "ssid1", ConnectionType.Ess, true, ConnectionMode.Auto, false, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
new object[] {"Profile1", null, null, null, true, null, null, Authentication.Wpa, null, KeyType.NetworkKey, 1, "keymaterial", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
new object[] {"Profile1", null, null, null, true, null, null, Authentication.Wpa, null, KeyType.NetworkKey, 1, "keymaterial", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
new object[] {"Profile1", null, null, null, true, ConnectionMode.Manual, null, Authentication.Open, null, null, null, null, true, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
new object[] {"Profile1", null, "ssid1", null, null, null, null, Authentication.Open, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
new object[] {"Profile1", null, "ssid1", null, null, null, true, Authentication.Open, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.HTTP
namespace Ignite.SharpNetSH.HTTP.Enums
{
public enum Timeout
{
Expand Down
1 change: 1 addition & 0 deletions SharpNetSH/Actions/HTTP/IAddAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Ignite.SharpNetSH.HTTP.Enums;

namespace Ignite.SharpNetSH.HTTP
{
Expand Down
1 change: 1 addition & 0 deletions SharpNetSH/Actions/HTTP/IDeleteAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Ignite.SharpNetSH.HTTP.Enums;

namespace Ignite.SharpNetSH.HTTP
{
Expand Down
6 changes: 3 additions & 3 deletions SharpNetSH/Actions/NetSh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public NetSH(IExecutionHarness harness)
/// <summary>
/// Instantiates a new instance of NetSH with a CommandLineHarness
/// </summary>
public static NetSH CMD { get { return new NetSH(new CommandLineHarness()); } }
public static NetSH CMD => new NetSH(new CommandLineHarness());

public IHttpAction Http { get { return HttpAction.CreateAction("netsh", _harness); } }
public IHttpAction Http => HttpAction.CreateAction("netsh", _harness);

public IWlanAction Wlan { get { return WlanAction.CreateAction("netsh", _harness); } }
public IWlanAction Wlan => WlanAction.CreateAction("netsh", _harness);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum AuthMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum Authentication
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum ConnectionMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum ConnectionType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum Cost
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum Display
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum Encryption
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum KeyType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum KeyUsage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum Mode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum NetworkMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum NetworkType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum Permission
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum ProfileType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum SsoMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum TracingMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Ignite.SharpNetSH.WLAN
namespace Ignite.SharpNetSH.WLAN.Enums
{
public enum User
{
Expand Down
1 change: 1 addition & 0 deletions SharpNetSH/Actions/WLAN/IAddAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Ignite.SharpNetSH.WLAN.Enums;

namespace Ignite.SharpNetSH.WLAN
{
Expand Down
1 change: 1 addition & 0 deletions SharpNetSH/Actions/WLAN/IDeleteAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Ignite.SharpNetSH.WLAN.Enums;

namespace Ignite.SharpNetSH.WLAN
{
Expand Down
1 change: 1 addition & 0 deletions SharpNetSH/Actions/WLAN/ISetAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Ignite.SharpNetSH.WLAN.Enums;

namespace Ignite.SharpNetSH.WLAN
{
Expand Down
1 change: 1 addition & 0 deletions SharpNetSH/Actions/WLAN/IShowAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Ignite.SharpNetSH.WLAN.Enums;

namespace Ignite.SharpNetSH.WLAN
{
Expand Down
2 changes: 1 addition & 1 deletion SharpNetSH/Actions/WLAN/WlanAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private WlanAction()

}

public string ActionName { get { return "wlan"; } }
public string ActionName => "wlan";

public void Initialize(string priorText, IExecutionHarness harness)
{
Expand Down
4 changes: 2 additions & 2 deletions SharpNetSH/Attributes/BooleanValueAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Ignite.SharpNetSH
[AttributeUsage(AttributeTargets.Field)]
internal class BooleanValueAttribute : Attribute
{
public String TrueValue { get; private set; }
public String FalseValue { get; private set; }
public String TrueValue { get; }
public String FalseValue { get; }

public BooleanValueAttribute(string trueValue, string falseValue)
{
Expand Down
2 changes: 1 addition & 1 deletion SharpNetSH/Attributes/MethodNameAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ internal class MethodNameAttribute : Attribute
public MethodNameAttribute(string methodName)
{ MethodName = methodName; }

public String MethodName { get; private set; }
public String MethodName { get; }
}
}
4 changes: 2 additions & 2 deletions SharpNetSH/Attributes/ParameterNameAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ParameterNameAttribute(string parameterName, BooleanType booleanType)
BooleanType = booleanType;
}

public String ParameterName { get; private set; }
public BooleanType BooleanType { get; private set; }
public String ParameterName { get; }
public BooleanType BooleanType { get; }
}
}
4 changes: 2 additions & 2 deletions SharpNetSH/Attributes/ResponseProcessorAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Ignite.SharpNetSH
[AttributeUsage(AttributeTargets.Method)]
internal class ResponseProcessorAttribute : Attribute
{
public Type ResponseProcessorType { get; private set; }
public String SplitRegEx { get; private set; }
public Type ResponseProcessorType { get; }
public String SplitRegEx { get; }

public ResponseProcessorAttribute(Type responseProcessorType, String splitRegEx = null)
{
Expand Down
7 changes: 3 additions & 4 deletions SharpNetSH/Harnesses/CommandLineHarness.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;

namespace Ignite.SharpNetSH
Expand All @@ -9,7 +8,7 @@ namespace Ignite.SharpNetSH
/// </summary>
public class CommandLineHarness : IExecutionHarness
{
public IEnumerable<String> Execute(string action, out int exitCode)
public IEnumerable<string> Execute(string action, out int exitCode)
{
var process = new Process
{
Expand All @@ -26,7 +25,7 @@ public IEnumerable<String> Execute(string action, out int exitCode)

process.Start();

var lines = new List<String>();
var lines = new List<string>();
while (!process.StandardOutput.EndOfStream)
lines.Add(process.StandardOutput.ReadLine());

Expand Down
Loading

0 comments on commit d9b6beb

Please sign in to comment.