Esempio n. 1
0
        public void Find()
        {
            var         proxy = new ActivityProxy();
            ActivityDto first = GetActivityDto();

            first.Owner = ApiUserEmailAddress;
            proxy.Insert(first);
            Assert.AreNotEqual(0, first.Uid);

            var firstGet = (ActivityDto)proxy.GetByUid(first.Uid);

            ReflectionTester.AssertAreEqual(first, firstGet, "LastModified");

            ActivityDto second = GetActivityDto();

            second.Owner          = ApiUserEmailAddress;
            second.AttachedToType = "Contact";
            second.AttachedToUid  = MrSmith.Uid;
            proxy.Insert(second);

            var secondGet = (ActivityDto)proxy.GetByUid(second.Uid);

            ReflectionTester.AssertAreEqual(second, secondGet, "LastModified");

            List <ActivityDto> activities = proxy.FindList <ActivityDto>(ActivityProxy.ResponseXPath, "Type", "Meeting");

            Assert.AreNotEqual(0, activities.Count);

            List <ActivityDto> kazActivities = proxy.FindList <ActivityDto>(ActivityProxy.ResponseXPath, "Type", "Meeting", "Owner",
                                                                            ApiUserEmailAddress);

            Assert.AreNotEqual(0, kazActivities.Count);

            // all api/kaz should be part of activities
            AssertInList(kazActivities, activities);

            // delete
            proxy.DeleteByUid(first.Uid);
            try
            {
                firstGet = (ActivityDto)proxy.GetByUid(first.Uid);
            }
            catch (RestException exception)
            {
                Assert.AreEqual("RecordNotFoundException", exception.Type);
            }

            proxy.DeleteByUid(second.Uid);
            try
            {
                secondGet = (ActivityDto)proxy.GetByUid(second.Uid);
            }
            catch (RestException exception)
            {
                Assert.AreEqual("RecordNotFoundException", exception.Type);
            }
        }
Esempio n. 2
0
        public void FindAttachedToContact()
        {
            var         proxy  = new ActivityProxy();
            ActivityDto entity = GetActivityDto();

            entity.Owner          = ApiUserEmailAddress;
            entity.AttachedToType = "Contact";
            entity.AttachedToUid  = MrSmith.Uid;
            proxy.Insert(entity);

            List <ActivityDto> apiActivities = proxy.FindList <ActivityDto>(ActivityProxy.ResponseXPath, "Type", "Meeting", "Owner",
                                                                            ApiUserEmailAddress, "AttachedToType", "Contact",
                                                                            "AttachedToUid", MrSmith.Uid.ToString());

            Assert.AreNotEqual(0, apiActivities.Count);

            bool found = false;

            foreach (ActivityDto activity in apiActivities)
            {
                Assert.AreEqual(entity.AttachedToUid, activity.AttachedToUid);
                Assert.AreEqual(entity.AttachedToType, activity.AttachedToType);

                if (activity.Uid == entity.Uid)
                {
                    found = true;
                }
            }
            if (!found)
            {
                Assert.Fail("Could not find entity {0} attached to contact.", entity.Uid);
            }

            proxy.DeleteByUid(entity.Uid);
        }