Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the MbDotNet.Enums namespace #127

Merged
merged 2 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MbDotNet.Tests/Acceptance/DocumentationTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using MbDotNet.Enums;
using MbDotNet.Models;
using MbDotNet.Models.Imposters;
using MbDotNet.Models.Predicates;
using MbDotNet.Models.Predicates.Fields;
using MbDotNet.Models.Responses;
Expand Down
2 changes: 1 addition & 1 deletion MbDotNet.Tests/Acceptance/ImposterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using MbDotNet.Enums;
using MbDotNet.Exceptions;
using MbDotNet.Models;
using MbDotNet.Models.Predicates;
using MbDotNet.Models.Predicates.Fields;
using MbDotNet.Models.Stubs;
Expand Down
1 change: 0 additions & 1 deletion MbDotNet.Tests/Acceptance/ResponseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using MbDotNet.Enums;
using MbDotNet.Exceptions;
using MbDotNet.Models.Predicates;
using MbDotNet.Models.Predicates.Fields;
Expand Down
2 changes: 1 addition & 1 deletion MbDotNet.Tests/Client/CreateTcpImposterTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Threading.Tasks;
using MbDotNet.Enums;
using MbDotNet.Models;
using MbDotNet.Models.Imposters;
using MbDotNet.Models.Responses.Fields;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
2 changes: 1 addition & 1 deletion MbDotNet.Tests/Models/Imposters/TcpImposterTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MbDotNet.Enums;
using MbDotNet.Models;
using MbDotNet.Models.Imposters;
using MbDotNet.Models.Responses.Fields;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
2 changes: 1 addition & 1 deletion MbDotNet.Tests/Models/Stubs/HttpStubTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Net;
using System.Text;
using MbDotNet.Enums;
using MbDotNet.Models;
using MbDotNet.Models.Predicates;
using MbDotNet.Models.Predicates.Fields;
using MbDotNet.Models.Responses;
Expand Down
2 changes: 1 addition & 1 deletion MbDotNet.Tests/Models/Stubs/TcpStubTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Linq;
using MbDotNet.Enums;
using MbDotNet.Models;
using MbDotNet.Models.Predicates;
using MbDotNet.Models.Predicates.Fields;
using MbDotNet.Models.Responses;
Expand Down
2 changes: 1 addition & 1 deletion MbDotNet/Models/Imposters/HttpImposter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class HttpImposter : Imposter, IWithStubs<HttpStub>, IWithResponseFields<
/// <param name="name">An optional name for the imposter</param>
/// <param name="options">Options for configuring the imposter</param>
public HttpImposter(int? port, string name, HttpImposterOptions options)
: base(port, Enums.Protocol.Http, name, options?.RecordRequests ?? false)
: base(port, Imposters.Protocol.Http, name, options?.RecordRequests ?? false)
{
Stubs = new List<HttpStub>();
AllowCORS = options?.AllowCORS ?? false;
Expand Down
2 changes: 1 addition & 1 deletion MbDotNet/Models/Imposters/HttpsImposter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public string Key
/// <param name="port">An optional port for the imposter to listen on</param>
/// <param name="name">An optional name for the imposter</param>
/// <param name="options">Options for configuring the imposter</param>
public HttpsImposter(int? port, string name, HttpsImposterOptions options) : base(port, Enums.Protocol.Https, name, options?.RecordRequests ?? false)
public HttpsImposter(int? port, string name, HttpsImposterOptions options) : base(port, Imposters.Protocol.Https, name, options?.RecordRequests ?? false)
{
Cert = options?.Cert;
Key = options?.Key;
Expand Down
1 change: 0 additions & 1 deletion MbDotNet/Models/Imposters/Imposter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using MbDotNet.Enums;
using MbDotNet.Exceptions;
using Newtonsoft.Json;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma warning disable CS1591
namespace MbDotNet.Enums
{
/// <summary>
/// Supported network protocols for defining imposters
/// </summary>
public enum Protocol
{
Http,
Https,
Tcp,
Smtp
}
}
#pragma warning disable CS1591
namespace MbDotNet.Models.Imposters
{
/// <summary>
/// Supported network protocols for defining imposters
/// </summary>
public enum Protocol
{
Http,
Https,
Tcp,
Smtp
}
}
1 change: 0 additions & 1 deletion MbDotNet/Models/Imposters/RetrievedTcpImposter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using MbDotNet.Enums;
using MbDotNet.Models.Requests;
using MbDotNet.Models.Responses.Fields;
using Newtonsoft.Json;
Expand Down
2 changes: 1 addition & 1 deletion MbDotNet/Models/Imposters/SmtpImposter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SmtpImposter : Imposter
/// <param name="name">An optional name for the imposter</param>
/// <param name="options">Options for configuring the imposter</param>
public SmtpImposter(int? port, string name, SmtpImposterOptions options)
: base(port, Enums.Protocol.Smtp, name, options?.RecordRequests ?? false)
: base(port, Imposters.Protocol.Smtp, name, options?.RecordRequests ?? false)
{
}
}
Expand Down
3 changes: 1 addition & 2 deletions MbDotNet/Models/Imposters/TcpImposter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using MbDotNet.Enums;
using MbDotNet.Models.Responses.Fields;
using MbDotNet.Models.Stubs;
using Newtonsoft.Json;
Expand Down Expand Up @@ -47,7 +46,7 @@ public TcpMode Mode
/// <param name="name">An optional name for the imposter</param>
/// <param name="options">Options for configuring the imposter</param>
public TcpImposter(int? port, string name, TcpImposterOptions options)
: base(port, Enums.Protocol.Tcp, name, options?.RecordRequests ?? false)
: base(port, Imposters.Protocol.Tcp, name, options?.RecordRequests ?? false)
{
Mode = options?.Mode ?? TcpMode.Text;
DefaultResponse = options?.DefaultResponse;
Expand Down
3 changes: 1 addition & 2 deletions MbDotNet/Models/Imposters/TcpImposterOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using MbDotNet.Enums;
using MbDotNet.Models.Responses.Fields;
using MbDotNet.Models.Responses.Fields;

namespace MbDotNet.Models.Imposters
{
Expand Down
24 changes: 12 additions & 12 deletions MbDotNet/Enums/TcpMode.cs → MbDotNet/Models/Imposters/TcpMode.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma warning disable CS1591
namespace MbDotNet.Enums
{
/// <summary>
/// Defines the encoding used for request and response strings in TCP imposters
/// </summary>
public enum TcpMode
{
Text,
Binary
}
}
#pragma warning disable CS1591
namespace MbDotNet.Models.Imposters
{
/// <summary>
/// Defines the encoding used for request and response strings in TCP imposters
/// </summary>
public enum TcpMode
{
Text,
Binary
}
}
38 changes: 19 additions & 19 deletions MbDotNet/Enums/Method.cs → MbDotNet/Models/Method.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#pragma warning disable CS1591
namespace MbDotNet.Enums
{
/// <summary>
/// HTTP Method
/// </summary>
public enum Method
{
Get,
Post,
Patch,
Delete,
Put,
Head,
Trace,
Options,
Connect
}
}
#pragma warning disable CS1591
namespace MbDotNet.Models
{
/// <summary>
/// HTTP Method
/// </summary>
public enum Method
{
Get,
Post,
Patch,
Delete,
Put,
Head,
Trace,
Options,
Connect
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;
using MbDotNet.Enums;
using Newtonsoft.Json;

namespace MbDotNet.Models.Predicates.Fields
Expand Down
1 change: 0 additions & 1 deletion MbDotNet/Models/Predicates/Fields/HttpPredicateFields.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using MbDotNet.Enums;
using Newtonsoft.Json;

namespace MbDotNet.Models.Predicates.Fields
Expand Down
41 changes: 21 additions & 20 deletions MbDotNet/Enums/ProxyMode.cs → MbDotNet/Models/ProxyMode.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
using System.Runtime.Serialization;
#pragma warning disable CS1591

namespace MbDotNet.Enums
{
/// <summary>
/// Mode for proxy responses
/// </summary>
public enum ProxyMode
{
[EnumMember(Value = "proxyOnce")]
ProxyOnce,

[EnumMember(Value = "proxyAlways")]
ProxyAlways,

[EnumMember(Value = "proxyTransparent")]
ProxyTransparent
}
}
using System.Runtime.Serialization;

#pragma warning disable CS1591

namespace MbDotNet.Models
{
/// <summary>
/// Mode for proxy responses
/// </summary>
public enum ProxyMode
{
[EnumMember(Value = "proxyOnce")]
ProxyOnce,

[EnumMember(Value = "proxyAlways")]
ProxyAlways,

[EnumMember(Value = "proxyTransparent")]
ProxyTransparent
}
}
1 change: 0 additions & 1 deletion MbDotNet/Models/Requests/HttpRequest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using MbDotNet.Enums;
using Newtonsoft.Json;

namespace MbDotNet.Models.Requests
Expand Down
1 change: 0 additions & 1 deletion MbDotNet/Models/Responses/Fields/ProxyResponseFields.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using MbDotNet.Enums;
using MbDotNet.Models.Predicates;
using MbDotNet.Models.Predicates.Fields;
using Newtonsoft.Json;
Expand Down
1 change: 0 additions & 1 deletion MbDotNet/Models/Stubs/HttpStub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using MbDotNet.Enums;
using MbDotNet.Models.Predicates;
using MbDotNet.Models.Predicates.Fields;
using MbDotNet.Models.Responses;
Expand Down
1 change: 0 additions & 1 deletion MbDotNet/Models/Stubs/TcpStub.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MbDotNet.Enums;
using MbDotNet.Models.Predicates;
using MbDotNet.Models.Predicates.Fields;
using MbDotNet.Models.Responses;
Expand Down
1 change: 0 additions & 1 deletion MbDotNet/MountebankClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MbDotNet.Enums;
using MbDotNet.Exceptions;
using MbDotNet.Models;
using MbDotNet.Models.Imposters;
Expand Down
14 changes: 14 additions & 0 deletions docs/v4-to-v5-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ There were a handful of breaking changes introduced in v5.x of the library. Thes
- The following types have been renamed: `StubBase` -> `Stub`, `PredicateBase` -> `Predicate`, `ResponseBase` -> `Response`
- This should not impact most users since these are abstract base classes
- If a `Key` or `Cert` are provided when creating an HTTPS imposter they will now be validated and an exception will be thrown if they are not valid PEM-formatted strings
- The `MbDotNet.Enums` namespace has been removed and its types moved elsewhere

Continue reading for detailed guidance on the updates you may need to make in order to upgrade to v5.x of the package.

Expand Down Expand Up @@ -161,3 +162,16 @@ var imposter = new HttpsImposter(4545, "MyImposter", new HttpsImposterConfigurat
Cert = "-----BEGIN CERTIFICATE-----base64_encoded_data-----END CERTIFICATE-----"
});
```

## Removal of `MbDotNet.Enums` namespace

The `MbDotNet.Enums` namespace has been removed since it did not make sense to group those types by what they are vs. what they represent.

The following types have been moved to the specified namespaces:

- `MbDotNet.Enums.Method` -> `MbDotNet.Models.Method`
- `MbDotNet.Enums.ProxyMode` -> `MbDotNet.Models.ProxyMode`
- `MbDotNet.Enums.Protocol` -> `MbDotNet.Models.Imposters.Protocol`
- `MbDotNet.Enums.TcpMode` -> `MbDotNet.Models.Imposters.TcpMode`

Any `using` statements for `MbDotNet.Enums` will need to be updated to reflect the new locations.