-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16410aa
commit 388052d
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using SMSApi.Api.Response.Subusers; | ||
|
||
namespace SMSApi.Api.Action.Subusers.Creation; | ||
|
||
public sealed class DeleteSubuser : Action<SubuserDeletionResult> | ||
{ | ||
private readonly string _userId; | ||
|
||
public DeleteSubuser(string userId) | ||
{ | ||
_userId = userId; | ||
} | ||
|
||
protected override RequestMethod Method => RequestMethod.DELETE; | ||
|
||
protected override string Uri() => $"subusers/{_userId}"; | ||
|
||
protected override ApiType ApiType() => Action.ApiType.Rest; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using SMSApi.Api.Response.ResponseResolver; | ||
|
||
namespace SMSApi.Api.Response.Subusers; | ||
|
||
public sealed class SubuserDeletionResult : IResponseCodeAwareResolver | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
smsapiTests/Unit/Action/Subusers/DeleteSubuserResponseTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Net; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SMSApi.Api; | ||
using SMSApi.Api.Action.Subusers.Creation; | ||
using smsapi.Api.Response.REST.Exception; | ||
using smsapiTests.Unit.Fixture; | ||
using smsapiTests.Unit.Helper; | ||
|
||
namespace smsapiTests.Unit.Action.Subusers; | ||
|
||
[TestClass] | ||
public class DeleteSubuserResponseTest | ||
{ | ||
private readonly ProxyStub _proxyStub = new(); | ||
|
||
[TestMethod] | ||
public void delete_subuser() | ||
{ | ||
var subuserId = "1238f47da26ee45dc41fb987"; | ||
_proxyStub.SyncExecutionResponse = new HttpResponseEntity( | ||
DictionaryToStreamHelper.EmptyStream, | ||
HttpStatusCode.NoContent | ||
); | ||
|
||
DeleteSubuser(subuserId); | ||
|
||
Assert.IsTrue(true); | ||
} | ||
|
||
[TestMethod] | ||
public void map_http_404_to_not_found_exception() | ||
{ | ||
_proxyStub.SyncExecutionResponse = new HttpResponseEntity( | ||
DictionaryToStreamHelper.EmptyStream, | ||
HttpStatusCode.NotFound | ||
); | ||
|
||
var result = () => { DeleteSubuser(); }; | ||
|
||
Assert.ThrowsException<NotFoundException>(result); | ||
} | ||
|
||
private void DeleteSubuser(string userId = "any") | ||
{ | ||
var action = new DeleteSubuser(userId); | ||
action.Proxy(_proxyStub); | ||
|
||
action.Execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SMSApi.Api; | ||
using SMSApi.Api.Action.Subusers.Creation; | ||
|
||
namespace smsapiTests.Unit.Action.Subusers; | ||
|
||
[TestClass] | ||
public class DeleteSubuserTest | ||
{ | ||
private readonly ProxyAssert _proxyAssert; | ||
private readonly SpyProxy _spyProxy = new(); | ||
|
||
public DeleteSubuserTest() | ||
{ | ||
_proxyAssert = new ProxyAssert(_spyProxy); | ||
} | ||
|
||
[TestMethod] | ||
public void use_delete_request_method() | ||
{ | ||
DeleteSubuser(); | ||
|
||
_proxyAssert.AssertRequestMethod(RequestMethod.DELETE); | ||
} | ||
|
||
[TestMethod] | ||
public void request_proper_uri() | ||
{ | ||
var userId = "1238f47da26ee45dc41fb987"; | ||
|
||
DeleteSubuser(userId); | ||
|
||
_proxyAssert.AssertUriEquals($"subusers/{userId}"); | ||
} | ||
|
||
private void DeleteSubuser(string userId = "any") | ||
{ | ||
var action = new DeleteSubuser(userId); | ||
action.Proxy(_spyProxy); | ||
|
||
action.Execute(); | ||
} | ||
} |