public void SetObjectFromKeyAndDataObjectWithKey()
        {
            Task <CMUserResponse <CMUserProfileMock> > loginResponse = userService.Login <CMUserProfileMock> (user);

            loginResponse.Wait();

            // ensure the login was successful
            Assert.AreEqual(loginResponse.Result.Status, HttpStatusCode.OK);
            Assert.That(loginResponse.Result.HasErrors, Is.False);
            Assert.AreEqual(loginResponse.Result.CMUser.Session, user.Session);              // ensure session set

            // lets create a user object
            PIIMock pii = new PIIMock()
            {
                FirstName            = "Jane",
                LastName             = "Doe",
                SocialSecurityNumber = "333-22-4444"
            };

            Task <CMObjectResponse> objResponse = userService.SetUserObject <PIIMock> (user, pii);

            objResponse.Wait();

            Assert.AreEqual(objResponse.Result.Status, HttpStatusCode.OK);
            Assert.That(objResponse.Result.HasErrors, Is.False);
            Assert.That(objResponse.Result.Success.ContainsKey(pii.ID), Is.True);
        }
        public void DeleteCMUserObject()
        {
            Task<CMUserResponse<CMUserProfileMock>> loginResponse = userService.Login<CMUserProfileMock> (user);
            loginResponse.Wait ();

            // ensure the login was successful
            Assert.AreEqual (loginResponse.Result.Status, HttpStatusCode.OK);
            Assert.That (loginResponse.Result.HasErrors, Is.False);
            Assert.AreEqual (loginResponse.Result.CMUser.Session, user.Session); // ensure session set

            // lets create a user object
            PIIMock pii = new PIIMock () {
                FirstName = "Jane",
                LastName = "Doe",
                SocialSecurityNumber = "333-22-4444"
            };

            Task<CMObjectResponse> objResponse = userService.SetUserObject<PIIMock> (user, pii);
            objResponse.Wait ();

            Assert.AreEqual (objResponse.Result.Status, HttpStatusCode.OK);
            Assert.That (objResponse.Result.HasErrors, Is.False);
            Assert.That (objResponse.Result.Success.ContainsKey(pii.ID), Is.True);

            Task<CMObjectResponse> deleteResponse = userService.DeleteUserObject(user, pii.ID);
            deleteResponse.Wait ();

            Assert.AreEqual (deleteResponse.Result.Status, HttpStatusCode.OK);
            Assert.That (deleteResponse.Result.HasErrors, Is.False);
            Assert.That (deleteResponse.Result.Success.ContainsKey (pii.ID), Is.True);
        }
Example #3
0
        public void SearchObjectByClassAndCount()
        {
            Task <CMUserResponse <CMUserProfileMock> > loginResponse = userService.Login <CMUserProfileMock> (user);

            loginResponse.Wait();

            // ensure the login was successful
            Assert.AreEqual(loginResponse.Result.Status, HttpStatusCode.OK);
            Assert.That(loginResponse.Result.HasErrors, Is.False);
            Assert.AreEqual(loginResponse.Result.CMUser.Session, user.Session);              // ensure session set

            // lets create a user object
            PIIMock pii = new PIIMock()
            {
                FirstName            = "Jane",
                LastName             = "Doe",
                SocialSecurityNumber = "333-22-4444"
            };

            Task <CMObjectResponse> objResponse = userService.SetUserObject <PIIMock> (user, pii);

            objResponse.Wait();

            Assert.AreEqual(objResponse.Result.Status, HttpStatusCode.OK);
            Assert.That(objResponse.Result.HasErrors, Is.False);
            Assert.That(objResponse.Result.Success.ContainsKey(pii.ID), Is.True);

            // get by id
            Task <CMObjectFetchResponse <PIIMock> > getResponse = userService.GetUserObject <PIIMock> (user, pii.ID);

            getResponse.Wait();

            Assert.AreEqual(getResponse.Result.Status, HttpStatusCode.OK);

            CMRequestOptions opts = new CMRequestOptions()
            {
                Parameters = new System.Collections.Generic.Dictionary <string, string> ()
                {
                    { "shared", "true" },
                    { "shared_only", "false" }
                }
            };

            // search
            Task <CMObjectSearchResponse <PIIMock> > searchResponse = userService.SearchUserObjects <PIIMock> (user, @"[__class__=""PIIMock"", FirstName=""Jane""]", opts);

            searchResponse.Wait();

            Assert.AreEqual(searchResponse.Result.Status, HttpStatusCode.OK);
            Assert.That(searchResponse.Result.HasErrors, Is.False);
            Assert.That(searchResponse.Result.Success.ContainsKey(pii.ID), Is.True);
            Assert.AreEqual(searchResponse.Result.Success [pii.ID].GetType(), typeof(PIIMock));
        }
        public void SearchObjectByClassAndCount()
        {
            Task<CMUserResponse<CMUserProfileMock>> loginResponse = userService.Login<CMUserProfileMock> (user);
            loginResponse.Wait ();

            // ensure the login was successful
            Assert.AreEqual (loginResponse.Result.Status, HttpStatusCode.OK);
            Assert.That (loginResponse.Result.HasErrors, Is.False);
            Assert.AreEqual (loginResponse.Result.CMUser.Session, user.Session); // ensure session set

            // lets create a user object
            PIIMock pii = new PIIMock () {
                FirstName = "Jane",
                LastName = "Doe",
                SocialSecurityNumber = "333-22-4444"
            };

            Task<CMObjectResponse> objResponse = userService.SetUserObject<PIIMock> (user, pii);
            objResponse.Wait ();

            Assert.AreEqual (objResponse.Result.Status, HttpStatusCode.OK);
            Assert.That (objResponse.Result.HasErrors, Is.False);
            Assert.That (objResponse.Result.Success.ContainsKey(pii.ID), Is.True);

            // get by id
            Task<CMObjectFetchResponse<PIIMock>> getResponse = userService.GetUserObject<PIIMock> (user, pii.ID);
            getResponse.Wait ();

            Assert.AreEqual (getResponse.Result.Status, HttpStatusCode.OK);

            CMRequestOptions opts = new CMRequestOptions () {
                Parameters = new System.Collections.Generic.Dictionary<string, string> () {
                    { "shared", "true" },
                    { "shared_only", "false" }
                }
            };

            // search
            Task<CMObjectSearchResponse<PIIMock>> searchResponse = userService.SearchUserObjects<PIIMock> (user, @"[__class__=""PIIMock"", FirstName=""Jane""]", opts);
            searchResponse.Wait ();

            Assert.AreEqual (searchResponse.Result.Status, HttpStatusCode.OK);
            Assert.That (searchResponse.Result.HasErrors, Is.False);
            Assert.That (searchResponse.Result.Success.ContainsKey (pii.ID), Is.True);
            Assert.AreEqual (searchResponse.Result.Success [pii.ID].GetType (), typeof(PIIMock));
        }