diff --git a/.gitignore b/.gitignore index be13aee..61bd58a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ PublishProfiles/ *.pidb *.userprefs *DS_Store -*.ncrunchsolution \ No newline at end of file +*.ncrunchsolution +.idea diff --git a/Toxiproxy.Net.Tests/ClientTests.cs b/Toxiproxy.Net.Tests/ClientTests.cs index 11944a6..1b8849b 100644 --- a/Toxiproxy.Net.Tests/ClientTests.cs +++ b/Toxiproxy.Net.Tests/ClientTests.cs @@ -6,12 +6,19 @@ namespace Toxiproxy.Net.Tests { [Collection("Integration")] - public class ClientTests : ToxiproxyTestsBase + public class ClientTests : IDisposable { + private readonly TestFixture _fixture; + + public ClientTests() + { + _fixture = new TestFixture(); + } + [Fact] public void ErrorsAreThrownCorrectly() { - var client = _connection.Client(); + var client = _fixture.Client(); Assert.Throws(() => { @@ -23,25 +30,25 @@ public void ErrorsAreThrownCorrectly() public void CanFindNamedProxy() { // Create a proxy and add the proxy to the client - var client = _connection.Client(); - client.Add(ProxyOne); + var client = _fixture.Client(); + client.Add(TestProxy.One); // Retrieve the proxy var proxy = client.FindProxy("one"); - // Check if it the corerct one + // Check if it the correct one Assert.NotNull(proxy); - Assert.Equal(proxy.Name, ProxyOne.Name); - Assert.Equal(proxy.Upstream, ProxyOne.Upstream); + Assert.Equal(proxy.Name, TestProxy.One.Name); + Assert.Equal(proxy.Upstream, TestProxy.One.Upstream); } [Fact] public void CanFindAllProxies() { // Create two proxies and add them to the client - var client = _connection.Client(); - client.Add(ProxyOne); - client.Add(ProxyTwo); + var client = _fixture.Client(); + client.Add(TestProxy.One); + client.Add(TestProxy.Two); // Retrieve all the proxies var all = client.All(); @@ -49,9 +56,9 @@ public void CanFindAllProxies() // Check if there are two proxies Assert.Equal(2, all.Keys.Count); // Check if contains the correct proxies - var containsProxyOne = all.Keys.Contains(ProxyOne.Name); + var containsProxyOne = all.Keys.Contains(TestProxy.One.Name); Assert.True(containsProxyOne); - var containsProxyTwo = all.Keys.Contains(ProxyTwo.Name); + var containsProxyTwo = all.Keys.Contains(TestProxy.Two.Name); Assert.True(containsProxyOne); } @@ -59,21 +66,21 @@ public void CanFindAllProxies() public void CanDeleteProxy() { // Add three proxies - var client = _connection.Client(); - client.Add(ProxyOne); - client.Add(ProxyTwo); - client.Add(ProxyThree); + var client = _fixture.Client(); + client.Add(TestProxy.One); + client.Add(TestProxy.Two); + client.Add(TestProxy.Three); // Delete two proxies - client.Delete(ProxyOne); - client.Delete(ProxyTwo.Name); + client.Delete(TestProxy.One); + client.Delete(TestProxy.Two.Name); // The client should contain only a proxy var all = client.All(); Assert.Equal(1, all.Keys.Count); // The single proxy in the collection should be the 3th proxy - var containsProxyThree = all.Keys.Contains(ProxyThree.Name); + var containsProxyThree = all.Keys.Contains(TestProxy.Three.Name); Assert.True(containsProxyThree); } @@ -81,11 +88,11 @@ public void CanDeleteProxy() public void CanUpdateProxy() { // Add a proxy - var client = _connection.Client(); - client.Add(ProxyOne); + var client = _fixture.Client(); + client.Add(TestProxy.One); // Retrieve the proxy and update the proxy - var proxyToUpdate = client.FindProxy(ProxyOne.Name); + var proxyToUpdate = client.FindProxy(TestProxy.One.Name); proxyToUpdate.Enabled = false; proxyToUpdate.Listen = "localhost:55555"; proxyToUpdate.Upstream = "google.com"; @@ -103,23 +110,23 @@ public void CanUpdateProxy() public void ResetWorks() { // Add a disabled proxy - var client = _connection.Client(); - client.Add(ProxyOne); + var client = _fixture.Client(); + client.Add(TestProxy.One); // Reset client.Reset(); - // Retrive the proxy - var proxyCopy = client.FindProxy(ProxyOne.Name); + // Retrieve the proxy + var proxyCopy = client.FindProxy(TestProxy.One.Name); // The proxy should be enabled - Assert.Equal(proxyCopy.Enabled, true); + Assert.True(proxyCopy.Enabled); } [Fact] public void CanNotAddANullProxy() { - var client = _connection.Client(); + var client = _fixture.Client(); Assert.Throws(() => client.Add(null)); } @@ -127,24 +134,24 @@ public void CanNotAddANullProxy() [Fact] public void CreateANewProxyShouldWork() { - var client = _connection.Client(); - var newProxy = client.Add(ProxyOne); + var client = _fixture.Client(); + var newProxy = client.Add(TestProxy.One); - Assert.Equal(ProxyOne.Name, newProxy.Name); - Assert.Equal(ProxyOne.Enabled, newProxy.Enabled); - Assert.Equal(ProxyOne.Listen, newProxy.Listen); - Assert.Equal(ProxyOne.Upstream, newProxy.Upstream); + Assert.Equal(TestProxy.One.Name, newProxy.Name); + Assert.Equal(TestProxy.One.Enabled, newProxy.Enabled); + Assert.Equal(TestProxy.One.Listen, newProxy.Listen); + Assert.Equal(TestProxy.One.Upstream, newProxy.Upstream); } [Fact] public void DeletingAProxyMoreThanOnceShouldThrowException() { // Add a proxy and check it exists - var client = _connection.Client(); - client.Add(ProxyOne); - var proxy = client.FindProxy(ProxyOne.Name); + var client = _fixture.Client(); + client.Add(TestProxy.One); + var proxy = client.FindProxy(TestProxy.One.Name); - // deleting is not idemnepotent and should throw exception + // deleting is not idempotent and should throw exception proxy.Delete(); var exception = Assert.Throws(() => proxy.Delete()); Assert.Equal("Not found", exception.Message); @@ -154,9 +161,9 @@ public void DeletingAProxyMoreThanOnceShouldThrowException() public void DeletingAProxyWorks() { // Add a proxy and check it exists - var client = _connection.Client(); - client.Add(ProxyOne); - var proxy = client.FindProxy(ProxyOne.Name); + var client = _fixture.Client(); + client.Add(TestProxy.One); + var proxy = client.FindProxy(TestProxy.One.Name); // delete proxy.Delete(); @@ -164,62 +171,69 @@ public void DeletingAProxyWorks() // check it doesn't exists Assert.Throws(() => { - client.FindProxy(ProxyOne.Name); + client.FindProxy(TestProxy.One.Name); }); - } - - [Fact] - public void AddToxic_NullFields() { - // Create a proxy and add the proxy to the client - var client = _connection.Client(); - client.Add( ProxyOne ); - - // Retrieve the proxy - var proxy = client.FindProxy( "one" ); - var latencyToxic = new LatencyToxic(); - latencyToxic.Attributes.Latency = 1000; - - proxy.Add( latencyToxic ); - proxy.Update(); - - var toxics = proxy.GetAllToxics(); - Assert.Equal( 1, toxics.Count() ); - var toxic = toxics.First(); - - Assert.Equal( 1, toxic.Toxicity ); - Assert.Equal( ToxicDirection.DownStream, toxic.Stream ); - - //default pattern is _ - Assert.Equal( "latency_downstream", toxic.Name ); - } - - [Fact] - public void AddToxic_NonNullFields() { - // Create a proxy and add the proxy to the client - var client = _connection.Client(); - client.Add( ProxyOne ); - - // Retrieve the proxy - var proxy = client.FindProxy( "one" ); - - var latencyToxic = new LatencyToxic(); - latencyToxic.Attributes.Latency = 1000; - latencyToxic.Stream = ToxicDirection.UpStream; - latencyToxic.Name = "testName"; - latencyToxic.Toxicity = 0.5; - - proxy.Add( latencyToxic ); - proxy.Update(); - - var toxics = proxy.GetAllToxics(); - Assert.Equal( 1, toxics.Count() ); - var toxic = toxics.First(); - - Assert.Equal( 0.5, toxic.Toxicity ); - Assert.Equal( ToxicDirection.UpStream, toxic.Stream ); - - //default pattern is _ - Assert.Equal( "testName", toxic.Name ); - } - } + } + + [Fact] + public void AddToxic_NullFields() { + // Create a proxy and add the proxy to the client + var client = _fixture.Client(); + client.Add(TestProxy.One); + + // Retrieve the proxy + var proxy = client.FindProxy( "one" ); + var latencyToxic = new LatencyToxic + { + Attributes = {Latency = 1000} + }; + + proxy.Add( latencyToxic ); + proxy.Update(); + + var toxics = proxy.GetAllToxics(); + Assert.True(toxics.Count() == 1); + var toxic = toxics.First(); + + Assert.True(toxic.Toxicity == 1); + Assert.Equal( ToxicDirection.DownStream, toxic.Stream ); + + //default pattern is _ + Assert.Equal( "latency_downstream", toxic.Name ); + } + + [Fact] + public void AddToxic_NonNullFields() { + // Create a proxy and add the proxy to the client + var client = _fixture.Client(); + client.Add(TestProxy.One); + + // Retrieve the proxy + var proxy = client.FindProxy( "one" ); + + var latencyToxic = new LatencyToxic + { + Attributes = {Latency = 1000}, + Stream = ToxicDirection.UpStream, + Name = "testName", + Toxicity = 0.5 + }; + + proxy.Add( latencyToxic ); + proxy.Update(); + + var toxics = proxy.GetAllToxics(); + Assert.True(toxics.Count() == 1); + var toxic = toxics.First(); + + Assert.Equal( 0.5, toxic.Toxicity); + Assert.Equal( ToxicDirection.UpStream, toxic.Stream ); + + //default pattern is _ + Assert.Equal( "testName", toxic.Name ); + } + + public void Dispose() + => _fixture?.Dispose(); + } } diff --git a/Toxiproxy.Net.Tests/ConnectionTests.cs b/Toxiproxy.Net.Tests/ConnectionTests.cs index 6c8ecb7..3968c0f 100644 --- a/Toxiproxy.Net.Tests/ConnectionTests.cs +++ b/Toxiproxy.Net.Tests/ConnectionTests.cs @@ -4,39 +4,43 @@ namespace Toxiproxy.Net.Tests { [Collection("Integration")] - public class ConnectionTests : ToxiproxyTestsBase + public class ConnectionTests : IDisposable { + private readonly TestFixture _fixture; + + public ConnectionTests() + { + _fixture = new TestFixture(); + } + [Fact] public void ErrorThrownIfHostIsNullOrEmpty() { - Assert.Throws(() => - { - var connection = new Connection(""); - - }); + Assert.Throws(() => { _ = new Connection(""); }); - Assert.Throws(() => - { - var connection = new Connection(null); - }); + Assert.Throws(() => { _ = new Connection(null); }); } [Fact] public void DisposeEnablesAndResetsAllProxies() { + _fixture.Client(); var connection = new Connection(resetAllToxicsAndProxiesOnClose: true); var client = connection.Client(); - client.Add(ProxyOne); + client.Add(TestProxy.One); - var proxy = client.FindProxy(ProxyOne.Name); + var proxy = client.FindProxy(TestProxy.One.Name); proxy.Enabled = false; proxy.Update(); connection.Dispose(); - var proxyCopy = client.FindProxy(ProxyOne.Name); + var proxyCopy = client.FindProxy(TestProxy.One.Name); Assert.True(proxyCopy.Enabled); } + + public void Dispose() + => _fixture?.Dispose(); } } \ No newline at end of file diff --git a/Toxiproxy.Net.Tests/Properties/AssemblyInfo.cs b/Toxiproxy.Net.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 2ed5918..0000000 --- a/Toxiproxy.Net.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Toxiproxy.Net.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Toxiproxy.Net.Tests")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f9f32664-b22f-4b72-8bb6-1bd360fbd490")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Toxiproxy.Net.Tests/ProxyTests.cs b/Toxiproxy.Net.Tests/ProxyTests.cs index ec5a480..63b8e1c 100644 --- a/Toxiproxy.Net.Tests/ProxyTests.cs +++ b/Toxiproxy.Net.Tests/ProxyTests.cs @@ -1,18 +1,26 @@ -using System.Linq; +using System; +using System.Linq; using Toxiproxy.Net.Toxics; using Xunit; namespace Toxiproxy.Net.Tests { [Collection("Integration")] - public class ProxyTests : ToxiproxyTestsBase + public class ProxyTests : IDisposable { + private readonly TestFixture _fixture; + + public ProxyTests() + { + _fixture = new TestFixture(); + } + [Fact] public void GetAllToxicsFromAProxyShouldWork() { // Add two toxics to a proxy and check if they are present in the list // of the toxies for the given proxy - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { Name = "testingProxy", @@ -62,7 +70,7 @@ public void GetAllToxicsFromAProxyShouldWork() [Fact] public void CreateANewLatencyToxicShouldWork() { - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { @@ -93,7 +101,7 @@ public void CreateANewLatencyToxicShouldWork() [Fact] public void CreateANewSlowCloseToxicShouldWork() { - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { @@ -123,7 +131,7 @@ public void CreateANewSlowCloseToxicShouldWork() [Fact] public void CreateANewTimeoutToxicShouldWork() { - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { @@ -153,7 +161,7 @@ public void CreateANewTimeoutToxicShouldWork() [Fact] public void CreateANewBandwidthToxicShouldWork() { - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { Name = "testingProxy", @@ -181,7 +189,7 @@ public void CreateANewBandwidthToxicShouldWork() [Fact] public void CreateANewSlicerToxicShouldWork() { - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { Name = "testingProxy", @@ -213,7 +221,7 @@ public void CreateANewSlicerToxicShouldWork() [Fact] public void CreateANewLimitDataToxicShouldWork() { - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { Name = "testingProxy", @@ -241,7 +249,7 @@ public void CreateANewLimitDataToxicShouldWork() [Fact] public void AddTwoToxicWithTheSameNameShouldThrowException() { - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { Name = "testingProxy", @@ -277,7 +285,7 @@ public void GetAnExistingToxicFromAProxyShouldWork() // Add a toxics to a proxy. // After reload the toxic again and check that all the properties // are correctly saved - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { Name = "testingProxy", @@ -317,7 +325,7 @@ public void DeleteAToxicShouldWork() // Add two toxics to a proxy. // After delete the first one and check that // there is still the second toxic in the proxy - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { Name = "testingProxy", @@ -353,7 +361,7 @@ public void DeleteAToxicShouldWork() // Retrieve the proxy and check that there is the // correct toxics var toxicsInProxy = newProxy.GetAllToxics(); - Assert.Equal(1, toxicsInProxy.Count()); + Assert.True(toxicsInProxy.Count() == 1); Assert.IsType(toxicsInProxy.First()); var singleToxicInProxy = (SlowCloseToxic)toxicsInProxy.First(); Assert.Equal(secondToxic.Name, singleToxicInProxy.Name); @@ -369,7 +377,7 @@ public void UpdatingAToxicShouldWorks() // After update all the toxic's properties // Reload the toxic again and check that all the properties // are correctly updated - var client = _connection.Client(); + var client = _fixture.Client(); var proxy = new Proxy { Name = "testingProxy", @@ -415,5 +423,8 @@ public void UpdatingAToxicShouldWorks() Assert.Equal(toxicInProxy.Attributes.Delay, specificToxicInProxy.Attributes.Delay); Assert.Equal(toxicInProxy.Attributes.SizeVariation, specificToxicInProxy.Attributes.SizeVariation); } + + public void Dispose() + => _fixture?.Dispose(); } } diff --git a/Toxiproxy.Net.Tests/TestFixture.cs b/Toxiproxy.Net.Tests/TestFixture.cs new file mode 100644 index 0000000..88395cc --- /dev/null +++ b/Toxiproxy.Net.Tests/TestFixture.cs @@ -0,0 +1,35 @@ +using System; +using System.Diagnostics; +using System.Threading; + +namespace Toxiproxy.Net.Tests +{ + public class TestFixture : IDisposable + { + private Process _process; + + public Client Client() + { + var exe = @"./toxiproxy-server-2.1.3.darwin-amd64"; + var processInfo = new ProcessStartInfo + { + FileName = exe + }; + _process = new Process + { + StartInfo = processInfo, + }; + + _process.Start(); + Thread.Sleep(500); + return new Connection().Client(); + } + + public void Dispose() + { + if (_process?.HasExited == false) + _process.Kill(); + } + + } +} diff --git a/Toxiproxy.Net.Tests/TestProxy.cs b/Toxiproxy.Net.Tests/TestProxy.cs new file mode 100644 index 0000000..a384607 --- /dev/null +++ b/Toxiproxy.Net.Tests/TestProxy.cs @@ -0,0 +1,29 @@ +namespace Toxiproxy.Net.Tests +{ + internal static class TestProxy + { + public static readonly Proxy One = new Proxy + { + Name = "one", + Enabled = true, + Listen = "127.0.0.1:11111", + Upstream = "one.com" + }; + + public static readonly Proxy Two = new Proxy + { + Name = "two", + Enabled = true, + Listen = "127.0.0.1:22222", + Upstream = "two.com" + }; + + public static readonly Proxy Three = new Proxy + { + Name = "three", + Enabled = true, + Listen = "127.0.0.1:33333", + Upstream = "three.com" + }; + } +} \ No newline at end of file diff --git a/Toxiproxy.Net.Tests/Toxiproxy.Net.Tests.csproj b/Toxiproxy.Net.Tests/Toxiproxy.Net.Tests.csproj index eae4da7..693c562 100644 --- a/Toxiproxy.Net.Tests/Toxiproxy.Net.Tests.csproj +++ b/Toxiproxy.Net.Tests/Toxiproxy.Net.Tests.csproj @@ -1,100 +1,23 @@ - - - - - - - Debug - AnyCPU - {10087FD2-3D58-47B6-A431-54B78AF4E2AA} - Library - Properties - Toxiproxy.Net.Tests - Toxiproxy.Net.Tests - v4.5 - 512 - ..\ - true - d28e86c2 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll - - - - - - - - - - False - ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll - - - False - ..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll - - - False - ..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll - - - - - - - - - - - - - Designer - - - - - - - - {6BD7B017-A750-4889-A66E-97B691838A8D} - Toxiproxy.Net - - - - - + + - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + netcoreapp2.1 + + false - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + diff --git a/Toxiproxy.Net.Tests/ToxiproxyTestsBase.cs b/Toxiproxy.Net.Tests/ToxiproxyTestsBase.cs deleted file mode 100644 index 161823a..0000000 --- a/Toxiproxy.Net.Tests/ToxiproxyTestsBase.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Diagnostics; - -namespace Toxiproxy.Net.Tests -{ - public class ToxiproxyTestsBase : IDisposable - { - protected Connection _connection; - protected Process _process; - - protected readonly Proxy ProxyOne = new Proxy - { - Name = "one", - Enabled = true, - Listen = "127.0.0.1:11111", - Upstream = "one.com" - }; - - protected readonly Proxy ProxyTwo = new Proxy { - Name = "two", - Enabled = true, - Listen = "127.0.0.1:22222", - Upstream = "two.com" - }; - - protected readonly Proxy ProxyThree = new Proxy { - Name = "three", - Enabled = true, - Listen = "127.0.0.1:33333", - Upstream = "three.com" - }; - - public ToxiproxyTestsBase() - { - var processInfo = new ProcessStartInfo() - { - FileName = @"..\..\..\compiled\Win64\toxiproxy-server-2.1.2-windows-amd64.exe" - }; - _process = new Process() - { - StartInfo = processInfo - }; - _process.Start(); - - _connection = new Connection(); - } - - public void Dispose() - { - if (_process.HasExited == false) - { - _process.Kill(); - } - } - } -} \ No newline at end of file diff --git a/Toxiproxy.Net.Tests/app.config b/Toxiproxy.Net.Tests/app.config deleted file mode 100644 index de5386a..0000000 --- a/Toxiproxy.Net.Tests/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Toxiproxy.Net.Tests/packages.config b/Toxiproxy.Net.Tests/packages.config deleted file mode 100644 index 88c1106..0000000 --- a/Toxiproxy.Net.Tests/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Toxiproxy.Net.sln b/Toxiproxy.Net.sln index fa80e50..1c46c57 100644 --- a/Toxiproxy.Net.sln +++ b/Toxiproxy.Net.sln @@ -1,18 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Toxiproxy.Net", "Toxiproxy.Net\Toxiproxy.Net.csproj", "{6BD7B017-A750-4889-A66E-97B691838A8D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToxiProxy.Net", "ToxiProxy.Net\ToxiProxy.Net.csproj", "{D8A50E37-2597-432A-A2C5-3133CEDA0C15}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{E1CEF3E4-9AED-4CC5-B296-EE8A196D9C09}" - ProjectSection(SolutionItems) = preProject - .nuget\NuGet.Config = .nuget\NuGet.Config - .nuget\NuGet.exe = .nuget\NuGet.exe - .nuget\NuGet.targets = .nuget\NuGet.targets - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Toxiproxy.Net.Tests", "Toxiproxy.Net.Tests\Toxiproxy.Net.Tests.csproj", "{10087FD2-3D58-47B6-A431-54B78AF4E2AA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToxiProxy.Net.Tests", "ToxiProxy.Net.Tests\ToxiProxy.Net.Tests.csproj", "{AA6A4E05-DE7B-48DA-9531-EDD16EE06DA5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -20,16 +10,13 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6BD7B017-A750-4889-A66E-97B691838A8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6BD7B017-A750-4889-A66E-97B691838A8D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6BD7B017-A750-4889-A66E-97B691838A8D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6BD7B017-A750-4889-A66E-97B691838A8D}.Release|Any CPU.Build.0 = Release|Any CPU - {10087FD2-3D58-47B6-A431-54B78AF4E2AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10087FD2-3D58-47B6-A431-54B78AF4E2AA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10087FD2-3D58-47B6-A431-54B78AF4E2AA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10087FD2-3D58-47B6-A431-54B78AF4E2AA}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE + {D8A50E37-2597-432A-A2C5-3133CEDA0C15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8A50E37-2597-432A-A2C5-3133CEDA0C15}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8A50E37-2597-432A-A2C5-3133CEDA0C15}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8A50E37-2597-432A-A2C5-3133CEDA0C15}.Release|Any CPU.Build.0 = Release|Any CPU + {AA6A4E05-DE7B-48DA-9531-EDD16EE06DA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA6A4E05-DE7B-48DA-9531-EDD16EE06DA5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA6A4E05-DE7B-48DA-9531-EDD16EE06DA5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA6A4E05-DE7B-48DA-9531-EDD16EE06DA5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Toxiproxy.Net/Connection.cs b/Toxiproxy.Net/Connection.cs index 153f02c..8ccc5be 100644 --- a/Toxiproxy.Net/Connection.cs +++ b/Toxiproxy.Net/Connection.cs @@ -2,17 +2,15 @@ namespace Toxiproxy.Net { + /// /// /// The class to connect to the ToxiProxy server /// - /// + /// public class Connection : IDisposable { private const int DefaultListeningPort = 8474; - private readonly string _host; - private readonly int _port; - private readonly IHttpClientFactory _clientFactory; private readonly bool _resetAllToxicsAndProxiesOnClose; @@ -34,16 +32,13 @@ public Connection(string host, int port, bool resetAllToxicsAndProxiesOnClose = { throw new ArgumentNullException("host"); } - _host = host; - _port = port; + _resetAllToxicsAndProxiesOnClose = resetAllToxicsAndProxiesOnClose; - _clientFactory = new HttpClientFactory(new Uri(string.Format("http://{0}:{1}/", _host, _port))); + _clientFactory = new HttpClientFactory(new Uri($"http://{host}:{port}/")); } public Client Client() - { - return new Client(_clientFactory); - } + => new Client(_clientFactory); public void Dispose() { diff --git a/Toxiproxy.Net/HttpClientFactory.cs b/Toxiproxy.Net/HttpClientFactory.cs index a5fa395..870039a 100644 --- a/Toxiproxy.Net/HttpClientFactory.cs +++ b/Toxiproxy.Net/HttpClientFactory.cs @@ -4,7 +4,7 @@ namespace Toxiproxy.Net { /// - /// The factory class to create preconfigured HttoClient + /// The factory class to create preconfigured HttpClient /// /// internal class HttpClientFactory : IHttpClientFactory diff --git a/Toxiproxy.Net/Properties/AssemblyInfo.cs b/Toxiproxy.Net/Properties/AssemblyInfo.cs deleted file mode 100644 index bfa81b2..0000000 --- a/Toxiproxy.Net/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Toxiproxy.Net")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Toxiproxy.Net")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e3a84440-728e-4ec3-af20-9bf8da0748db")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Toxiproxy.Net/Proxy.cs b/Toxiproxy.Net/Proxy.cs index 1b8e750..ac584c7 100644 --- a/Toxiproxy.Net/Proxy.cs +++ b/Toxiproxy.Net/Proxy.cs @@ -26,9 +26,7 @@ public void Delete() /// /// public Proxy Update() - { - return Client.Update(this); - } + => Client.Update(this); /// /// Adds the specified toxic to this proxy. @@ -37,18 +35,14 @@ public Proxy Update() /// The toxic. /// public T Add(T toxic) where T : ToxicBase - { - return Client.AddToxicToProxy(this, toxic); - } + => Client.AddToxicToProxy(this, toxic); /// /// Gets all the toxics. /// /// public IEnumerable GetAllToxics() - { - return Client.FindAllToxicsByProxyName(Name); - } + => Client.FindAllToxicsByProxyName(Name); /// /// Gets a toxic by name in this proxy. @@ -56,9 +50,7 @@ public IEnumerable GetAllToxics() /// The name. /// public ToxicBase GetToxicByName(string name) - { - return Client.FindToxicByProxyNameAndToxicName(this, name); - } + => Client.FindToxicByProxyNameAndToxicName(this, name); /// /// Removes the toxic. diff --git a/Toxiproxy.Net/Toxiproxy.Net.csproj b/Toxiproxy.Net/Toxiproxy.Net.csproj index 68293e1..64ed989 100644 --- a/Toxiproxy.Net/Toxiproxy.Net.csproj +++ b/Toxiproxy.Net/Toxiproxy.Net.csproj @@ -1,90 +1,16 @@ - - - - - Debug - AnyCPU - {6BD7B017-A750-4889-A66E-97B691838A8D} - Library - Properties - Toxiproxy.Net - Toxiproxy.Net - v4.5 - 512 - ..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - True - - - - - - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + netstandard2.0 - - - - \ No newline at end of file + + + + + + + + + + + diff --git a/Toxiproxy.Net/app.config b/Toxiproxy.Net/app.config deleted file mode 100644 index de5386a..0000000 --- a/Toxiproxy.Net/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Toxiproxy.Net/packages.config b/Toxiproxy.Net/packages.config deleted file mode 100644 index e105097..0000000 --- a/Toxiproxy.Net/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/compiled/Win64/LICENSE b/compiled/LICENSE similarity index 100% rename from compiled/Win64/LICENSE rename to compiled/LICENSE diff --git a/compiled/Win64/toxiproxy-server-2.1.2-windows-amd64.exe b/compiled/Win64/toxiproxy-server-2.1.2-windows-amd64.exe deleted file mode 100644 index 7216e60..0000000 Binary files a/compiled/Win64/toxiproxy-server-2.1.2-windows-amd64.exe and /dev/null differ diff --git a/compiled/toxiproxy-server-2.1.3.darwin-amd64 b/compiled/toxiproxy-server-2.1.3.darwin-amd64 new file mode 100755 index 0000000..1424a7f Binary files /dev/null and b/compiled/toxiproxy-server-2.1.3.darwin-amd64 differ diff --git a/compiled/toxiproxy-server-2.1.3.linux-amd64 b/compiled/toxiproxy-server-2.1.3.linux-amd64 new file mode 100644 index 0000000..3a5a622 Binary files /dev/null and b/compiled/toxiproxy-server-2.1.3.linux-amd64 differ diff --git a/compiled/toxiproxy-server-2.1.3.windows-amd64.exe b/compiled/toxiproxy-server-2.1.3.windows-amd64.exe new file mode 100644 index 0000000..a0d8bdb Binary files /dev/null and b/compiled/toxiproxy-server-2.1.3.windows-amd64.exe differ