public async Task RenameAsyncTest()
        {
            using (ParticleCloudMock cloud = new ParticleCloudMock())
            {
                cloud.RequestCallBack = (a, b, c) =>
                {
                    Assert.AreEqual("PUT", a);
                    Assert.AreEqual("devices/3", b);
                    Assert.AreEqual(1, c.Length);
                    var p1 = c[0];
                    Assert.AreEqual("name", p1.Key);
                    Assert.AreEqual("newTest", p1.Value);
                    return(new RequestResponse
                    {
                        StatusCode = System.Net.HttpStatusCode.OK,
                        Response = JToken.Parse(@"{
		  'error': 'Nothing to do?'
		}"        )
                    });
                };

                var p = new ParticleDeviceMock(cloud, JObject.Parse("{'id':'3', 'name': 'test'}"));

                var exc = Assert.Throws <ArgumentNullException>(() => { p.RenameAsync(null).GetAwaiter().GetResult(); });
                Assert.AreEqual("newName", exc.ParamName);

                var result = await p.RenameAsync("newTest");

                Assert.IsNotNull(result);
                Assert.IsFalse(result.Success);
                Assert.AreEqual("Nothing to do?", result.Error);

                cloud.RequestCallBack = (a, b, c) =>
                {
                    Assert.AreEqual("PUT", a);
                    Assert.AreEqual("devices/3", b);
                    Assert.AreEqual(1, c.Length);
                    var p1 = c[0];
                    Assert.AreEqual("name", p1.Key);
                    Assert.AreEqual("newTest", p1.Value);
                    return(new RequestResponse
                    {
                        StatusCode = System.Net.HttpStatusCode.OK,
                        Response = JToken.Parse(@"{
name: 'newTest',
id: '1234'
		}"        )
                    });
                };

                result = await p.RenameAsync("newTest");

                Assert.IsNotNull(result);
                Assert.IsTrue(result.Success);
            }
        }
        public async Task RenameAsyncHttpRequestExceptionTest()
        {
            using (ParticleCloudMock cloud = new ParticleCloudMock())
            {
                var ex = new HttpRequestException("Unable to resolve");
                cloud.RequestCallBack = (a, b, c) =>
                {
                    throw ex;
                };

                var p      = new ParticleDeviceMock(cloud, JObject.Parse("{'id':'3', 'name': 'test'}"));
                var result = await p.RenameAsync("cheese");

                Assert.IsNotNull(result);
                Assert.IsFalse(result.Success);
                Assert.AreEqual(ex.Message, result.Error);
                Assert.AreEqual(ex, result.Exception);
            }
        }
		public async Task RenameAsyncHttpRequestExceptionTest()
		{
			using (ParticleCloudMock cloud = new ParticleCloudMock())
			{
				var ex = new HttpRequestException("Unable to resolve");
				cloud.RequestCallBack = (a, b, c) =>
				{
					throw ex;
				};

				var p = new ParticleDeviceMock(cloud, JObject.Parse("{'id':'3', 'name': 'test'}"));
				var result = await p.RenameAsync("cheese");
				Assert.IsNotNull(result);
				Assert.IsFalse(result.Success);
				Assert.AreEqual(ex.Message, result.Error);
				Assert.AreEqual(ex, result.Exception);
			}
		}
		public async Task RenameAsyncTest()
		{
			using (ParticleCloudMock cloud = new ParticleCloudMock())
			{
				cloud.RequestCallBack = (a, b, c) =>
				{
					Assert.AreEqual("PUT", a);
					Assert.AreEqual("devices/3", b);
					Assert.AreEqual(1, c.Length);
					var p1 = c[0];
					Assert.AreEqual("name", p1.Key);
					Assert.AreEqual("newTest", p1.Value);
					return new RequestResponse
					{
						StatusCode = System.Net.HttpStatusCode.OK,
						Response = JToken.Parse(@"{
		  'error': 'Nothing to do?'
		}")
					};
				};

				var p = new ParticleDeviceMock(cloud, JObject.Parse("{'id':'3', 'name': 'test'}"));

				var exc = Assert.Throws<ArgumentNullException>(() => { p.RenameAsync(null).GetAwaiter().GetResult(); });
				Assert.AreEqual("newName", exc.ParamName);

				var result = await p.RenameAsync("newTest");
				Assert.IsNotNull(result);
				Assert.IsFalse(result.Success);
				Assert.AreEqual("Nothing to do?", result.Error);

				cloud.RequestCallBack = (a, b, c) =>
				{
					Assert.AreEqual("PUT", a);
					Assert.AreEqual("devices/3", b);
					Assert.AreEqual(1, c.Length);
					var p1 = c[0];
					Assert.AreEqual("name", p1.Key);
					Assert.AreEqual("newTest", p1.Value);
					return new RequestResponse
					{
						StatusCode = System.Net.HttpStatusCode.OK,
						Response = JToken.Parse(@"{
name: 'newTest',
id: '1234'
		}")
					};
				};

				result = await p.RenameAsync("newTest");
				Assert.IsNotNull(result);
				Assert.IsTrue(result.Success);
			}
		}