예제 #1
0
        public void TestBatchClaimUnclaim()
        {
            String uuid   = Guid.NewGuid().ToString();
            String value1 = "value-" + uuid;
            Owner  owner  = new Owner.Builder()
            {
                Username   = "******" + uuid,
                Password   = "******" + uuid,
                Attributes = new Dictionary <string, object>()
                {
                    { "owner_text_attribute", value1 }
                }
            };

            SmartObject smartObject = new SmartObject.Builder()
            {
                DeviceId   = "deviceId-" + uuid,
                ObjectType = "object_type1",
                Attributes = new Dictionary <string, object>()
                {
                    { "object_text_attribute", value1 }
                }
            };


            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "x_timestamp", "2017-04-24T16:13:11+00:00" }
            };
            IEnumerable <ClaimOrUnclaim> valid = new List <ClaimOrUnclaim>()
            {
                new ClaimOrUnclaim(owner.Username, smartObject.DeviceId, body)
            };
            IEnumerable <ClaimOrUnclaim> unknownUsername = new List <ClaimOrUnclaim>()
            {
                new ClaimOrUnclaim(uuid, smartObject.DeviceId, body)
            };
            IEnumerable <ClaimOrUnclaim> unknownDeviceId = new List <ClaimOrUnclaim>()
            {
                new ClaimOrUnclaim(owner.Username, uuid, body)
            };

            client.Owners.Create(owner);
            client.Objects.Create(smartObject);

            ITTestHelper.AllFailed(client.Owners.BatchClaim(unknownUsername));
            ITTestHelper.AllFailed(client.Owners.BatchClaim(unknownDeviceId));

            ITTestHelper.AllSuccess(client.Owners.BatchClaim(valid));

            ITTestHelper.AllFailed(client.Owners.BatchUnclaim(unknownUsername));
            ITTestHelper.AllFailed(client.Owners.BatchUnclaim(unknownDeviceId));

            ITTestHelper.AllSuccess(client.Owners.BatchUnclaim(valid));

            //Already unclaimed
            ITTestHelper.AllFailed(client.Owners.BatchUnclaim(valid));
        }
예제 #2
0
 public OwnersITTests()
 {
     client = ITTestHelper.newClient();
 }
예제 #3
0
        public void TestClaimUnclaim()
        {
            String uuid   = Guid.NewGuid().ToString();
            String value1 = "value-" + uuid;
            Owner  owner  = new Owner.Builder()
            {
                Username   = "******" + uuid,
                Password   = "******" + uuid,
                Attributes = new Dictionary <string, object>()
                {
                    { "owner_text_attribute", value1 }
                }
            };

            SmartObject smartObject = new SmartObject.Builder()
            {
                DeviceId   = "deviceId-" + uuid,
                ObjectType = "object_type1",
                Attributes = new Dictionary <string, object>()
                {
                    { "object_text_attribute", value1 }
                }
            };

            client.Owners.Create(owner);
            client.Objects.Create(smartObject);

            try {
                client.Owners.Claim(uuid, smartObject.DeviceId);
                Assert.Fail("Claim on a non existent owner should fail");
            } catch {
                //expected
            }

            try {
                client.Owners.Claim(owner.Username, uuid);
                Assert.Fail("Claim on a non existent owner should fail");
            } catch {
                //expected
            }

            client.Owners.Claim(owner.Username, smartObject.DeviceId);

            ITTestHelper.EventuallyAssert(() => {
                ResultSet resultOwn = client.Restitution.Search(ITTestHelper.searchObjectByOwnerQuery(owner.Username));
                Assert.AreEqual(1, resultOwn.Rows.Count);
            });

            try {
                client.Owners.Unclaim(uuid, smartObject.DeviceId);
                Assert.Fail("Unclaim on an non-existing owner should fail");
            } catch {
                //expected
            }
            try {
                client.Owners.Unclaim(owner.Username, uuid);
                Assert.Fail("Unclaim on an non-existing object should fail");
            } catch {
                //expected
            }

            client.Owners.Unclaim(owner.Username, smartObject.DeviceId);

            try {
                client.Owners.Unclaim(owner.Username, smartObject.DeviceId);
                Assert.Fail("Unclaim on an already unclaimed object should fail");
            } catch {
                //expected
            }
        }
예제 #4
0
 public SearchITTest()
 {
     client = ITTestHelper.newClient();
 }
예제 #5
0
 public EventsITTests()
 {
     client = ITTestHelper.newClient();
 }
예제 #6
0
 public ModelITTests()
 {
     client = ITTestHelper.newClient();
 }
예제 #7
0
 public ObjectsITTests()
 {
     client = ITTestHelper.newClient();
 }