Skip to content

Commit

Permalink
Fixes issue #11 - An ArgumentNullException is thrown for the delete o…
Browse files Browse the repository at this point in the history
…f an empty resource list
  • Loading branch information
ryannewington committed Mar 17, 2017
1 parent 782e0aa commit 3f7edc7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/Lithnet.ResourceManagement.Client.UnitTests/DeleteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ namespace Lithnet.ResourceManagement.Client.UnitTests
[TestClass]
public class DeleteTests
{
[TestMethod]
public void DeleteEmptyListResource()
{
ResourceManagementClient client = new ResourceManagementClient();

client.DeleteResources(new List<ResourceObject>());
}

[TestMethod]
public void DeleteEmptyListUniqueIdentifier()
{
ResourceManagementClient client = new ResourceManagementClient();

client.DeleteResources(new List<UniqueIdentifier>());
}

[TestMethod]
public void DeleteByID()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Put(IEnumerable<ResourceObject> resources)
{
throw new ArgumentNullException(nameof(resources));
}

using (Message message = MessageComposer.CreatePutMessage(resources.ToArray()))
{
if (message == null)
Expand Down Expand Up @@ -107,7 +107,14 @@ public void Delete(IEnumerable<UniqueIdentifier> resourceIDs)
throw new ArgumentNullException(nameof(resourceIDs));
}

using (Message message = MessageComposer.CreateDeleteMessage(resourceIDs.ToArray()))
UniqueIdentifier[] ids = resourceIDs.ToArray();

if (ids.Length == 0)
{
return;
}

using (Message message = MessageComposer.CreateDeleteMessage(ids))
{
using (Message responseMessage = this.Invoke((c) => c.Delete(message)))
{
Expand Down

0 comments on commit 3f7edc7

Please sign in to comment.