diff --git a/ValidicCSharp/Client.cs b/ValidicCSharp/Client.cs
index 479b438..a0c0791 100644
--- a/ValidicCSharp/Client.cs
+++ b/ValidicCSharp/Client.cs
@@ -81,11 +81,17 @@ public string ExecuteWebCommand(string command, HttpMethod method, object payloa
try
{
if (method == HttpMethod.GET)
+ {
json = client.DownloadString(address);
- if (method == HttpMethod.POST && payload != null)
+ }
+ else if (method == HttpMethod.POST && payload != null)
{
json = client.UploadString(address, JsonConvert.SerializeObject(payload));
}
+ else if (method == HttpMethod.DELETE)
+ {
+ json = client.UploadString(address, HttpMethod.DELETE.ToString(), string.Empty);
+ }
}
catch (WebException ex)
{
diff --git a/ValidicCSharp/Model/AddUserResponse.cs b/ValidicCSharp/Model/AddUserResponse.cs
index 4b9491c..a9bd320 100644
--- a/ValidicCSharp/Model/AddUserResponse.cs
+++ b/ValidicCSharp/Model/AddUserResponse.cs
@@ -1,9 +1,7 @@
namespace ValidicCSharp.Model
{
- public class AddUserResponse
+ public class AddUserResponse : BaseResponse
{
- public int code { get; set; }
- public string message { get; set; }
public User user { get; set; }
}
}
\ No newline at end of file
diff --git a/ValidicCSharp/Model/BaseResponse.cs b/ValidicCSharp/Model/BaseResponse.cs
new file mode 100644
index 0000000..a1f2fcd
--- /dev/null
+++ b/ValidicCSharp/Model/BaseResponse.cs
@@ -0,0 +1,10 @@
+namespace ValidicCSharp.Model
+{
+ using System.Net;
+
+ public class BaseResponse
+ {
+ public int code { get; set; }
+ public string message { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ValidicCSharp/Request/Command.cs b/ValidicCSharp/Request/Command.cs
index 9eaf19d..ed5cd07 100644
--- a/ValidicCSharp/Request/Command.cs
+++ b/ValidicCSharp/Request/Command.cs
@@ -154,7 +154,13 @@ public static Command GetLatest(this Command command)
return command;
}
- public static string GetStringAndStripRandom(this Command command)
+ public static Command DeleteUser(this Command command, string userId)
+ {
+ command.Method = HttpMethod.DELETE;
+ return command.FromUser(userId);
+ }
+
+ public static string GetStringAndStripRandom(this Command command)
{
var text = command.ToString();
var split = text.Split('?');
diff --git a/ValidicCSharp/ValidicCSharp.csproj b/ValidicCSharp/ValidicCSharp.csproj
index 62aca53..196b952 100644
--- a/ValidicCSharp/ValidicCSharp.csproj
+++ b/ValidicCSharp/ValidicCSharp.csproj
@@ -49,6 +49,7 @@
+
diff --git a/ValidicCSharpTests/CustomerModel.cs b/ValidicCSharpTests/CustomerModel.cs
index bf0d4cc..ef23636 100644
--- a/ValidicCSharpTests/CustomerModel.cs
+++ b/ValidicCSharpTests/CustomerModel.cs
@@ -27,5 +27,15 @@ public AddUserResponse AddUser(string uid, Profile profile = null)
var response = json.Objectify();
return response;
}
- }
+
+
+ public BaseResponse DeleteUser(string validicId)
+ {
+ var client = new Client() { AccessToken = Credentials.AccessToken };
+ var command = new Command().DeleteUser(validicId).FromOrganization(Credentials.OrganizationId);
+ var json = client.PerformCommand(command);
+ var response = json.Objectify();
+ return response;
+ }
+}
}
\ No newline at end of file
diff --git a/ValidicCSharpTests/ModelTests.cs b/ValidicCSharpTests/ModelTests.cs
index a458e93..0b6f85c 100644
--- a/ValidicCSharpTests/ModelTests.cs
+++ b/ValidicCSharpTests/ModelTests.cs
@@ -14,7 +14,7 @@ public class ModelTests : BaseTests
{
public static CustomerModel Acme = new CustomerModel
{
- Credentials = new OrganizationAuthenticationCredentials{ OrganizationId = "51aca5a06dedda916400002b", AccessToken = "ENTERPRISE_KEY"},
+ Credentials = new OrganizationAuthenticationCredentials { OrganizationId = "51aca5a06dedda916400002b", AccessToken = "ENTERPRISE_KEY" },
Organization = new Organization{Name = "ACME Corp"},
Profile = new Profile { Uid = "52ffcb4bf1f70eefba000004", Gender = GenderType.M}
};
@@ -72,6 +72,7 @@ public void CanAddUser()
Assert.IsTrue(response.user._id != null);
Assert.IsTrue(response.code == (int)StatusCode.Created);
}
+
[Test]
public void AddUserWithSameId()
{
@@ -94,6 +95,23 @@ public void CanAddUserWithProfile()
Assert.IsTrue(response.user.profile.Gender == GenderType.M);
}
+ [Test]
+ public void CanAddAndDeleteUser()
+ {
+ var response = Customer.AddUser(MakeRandom().ToString());
+ Assert.IsTrue(response.user._id != null);
+ Assert.AreEqual((int)StatusCode.Created, response.code);
+ var deleteResponse = Customer.DeleteUser(response.user._id);
+ Assert.AreEqual((int)StatusCode.Ok, (int)deleteResponse.code);
+ }
+
+ [Test]
+ public void DeleteNonExistantUser()
+ {
+ var deleteResponse = Customer.DeleteUser(MakeRandom().ToString());
+ Assert.AreEqual((int)StatusCode.NotFound, (int)deleteResponse.code);
+ }
+
[Test]
public void DiabetesModelPopulatesCorrectly()