コード例 #1
0
        public void InsertAttachedTo()
        {
            var         proxy = new ActivityProxy();
            ActivityDto dto   = GetActivityDto();

            dto.Owner          = ApiUserEmailAddress;
            dto.AttachedToType = "Sale";
            dto.AttachedToUid  = _sale1.Uid;

            proxy.Insert(dto);
            var result = (ActivityDto)proxy.GetByUid(dto.Uid);

            ReflectionTester.AssertAreEqual(dto, result, "LastModified", "UtcLastModified");

            dto                = GetActivityDto();
            dto.Owner          = ApiUserEmailAddress;
            dto.AttachedToType = "Purchase";
            dto.AttachedToUid  = _purchase1.Uid;

            proxy.Insert(dto);
            result = (ActivityDto)proxy.GetByUid(dto.Uid);
            ReflectionTester.AssertAreEqual(dto, result, "LastModified", "UtcLastModified");

            dto                = GetActivityDto();
            dto.Owner          = ApiUserEmailAddress;
            dto.AttachedToType = "Contact";
            dto.AttachedToUid  = MrSmith.Uid;

            proxy.Insert(dto);
            result = (ActivityDto)proxy.GetByUid(dto.Uid);
            ReflectionTester.AssertAreEqual(dto, result, "LastModified", "UtcLastModified");
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public void TryGetByLastModified()
        {
            var proxy = new ActivityProxy();

            ActivityDto first = GetActivityDto();

            first.Owner = ApiUserEmailAddress;
            Thread.Sleep(2 * 1000);
            proxy.Insert(first);

            var      retrived    = (ActivityDto)proxy.GetByUid(first.Uid);
            DateTime firstInsert = retrived.LastModified.AddSeconds(-1); // go back once


            Thread.Sleep(5 * 1000);

            ActivityDto second = GetActivityDto();

            second.Owner = ApiUserEmailAddress;
            Thread.Sleep(2 * 1000);
            proxy.Insert(second);

            retrived = (ActivityDto)proxy.GetByUid(second.Uid);
            DateTime secondInsert = retrived.LastModified.AddSeconds(-1);             // go back once


            var dateFrom = secondInsert;
            var dateTo   = DateTime.UtcNow.AddMinutes(5);
            List <ActivityDto> secondOnly = proxy.FindList <ActivityDto>(ActivityProxy.ResponseXPath, "datetype", "modified",
                                                                         "Owner", ApiUserEmailAddress, "DateFrom",
                                                                         dateFrom.ToString("s"), "DateTo",
                                                                         dateTo.ToString("s"));

            Assert.IsTrue(secondOnly.Count >= 1);
            foreach (var activityDto in secondOnly)
            {
                Assert.IsTrue(activityDto.LastModified >= dateFrom && activityDto.LastModified <= dateTo, "Activity where last mod outside date range included. ActivityId: {0}.", activityDto.Uid);
            }

            ReflectionTester.AssertAreEqual(second, secondOnly[0], new[] { "LastModified", "UtcLastModified" });

            List <ActivityDto> firstAndSecond = proxy.FindList <ActivityDto>(ActivityProxy.ResponseXPath, "datetype", "modified",
                                                                             "Owner", ApiUserEmailAddress, "DateFrom",
                                                                             firstInsert.ToString("s"), "DateTo",
                                                                             DateTime.UtcNow.AddMinutes(5).ToString("s"));

            Assert.AreEqual(2, firstAndSecond.Count);
            ReflectionTester.AssertAreEqual(first, firstAndSecond[1], new[] { "LastModified", "UtcLastModified" });
            ReflectionTester.AssertAreEqual(second, firstAndSecond[0], new[] { "LastModified", "UtcLastModified" });
        }
コード例 #4
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);
        }
コード例 #5
0
        public void TryInsertAttachedToDifferentFileUid()
        {
            var         proxy = new ActivityProxy();
            ActivityDto dto   = GetActivityDto();

            dto.Owner          = ApiUserEmailAddress;
            dto.AttachedToType = "Contact";
            dto.AttachedToUid  = 186600;            // this contact is not part of this file!!!
            proxy.Insert(dto);
        }
コード例 #6
0
        public void TestInsertAndGetByUid()
        {
            var         proxy  = new ActivityProxy();
            ActivityDto insert = GetActivityDto();

            proxy.Insert(insert);

            Assert.IsTrue(insert.Uid > 0, "Uid must be > 0 after save.");

            var read = (ActivityDto)proxy.GetByUid(insert.Uid);

            ReflectionTester.AssertAreEqual("Activity", insert, read, new[] { "LastModified", "UtcLastModified", "Tags" });
        }
コード例 #7
0
        public void TestIsDoneFlagUpdate()
        {
            var         proxy  = new ActivityProxy();
            ActivityDto insert = GetActivityDto();

            proxy.Insert(insert);

            var read = (ActivityDto)proxy.GetByUid(insert.Uid);

            read.Done = true;
            proxy.Update(read);

            var doneActivity = (ActivityDto)proxy.GetByUid(insert.Uid);

            Assert.IsTrue(doneActivity.Done);
        }
コード例 #8
0
        public void Update()
        {
            var         proxy = new ActivityProxy();
            ActivityDto dto   = GetActivityDto();

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after save.");

            dto.Title = "A nee Title.";
            dto.Type  = "Note";

            proxy.Update(dto);

            var read = (ActivityDto)proxy.GetByUid(dto.Uid);

            ReflectionTester.AssertAreEqual("Activity", dto, read, "LastModified", "UtcLastModified");
        }
コード例 #9
0
        public void TryInsertAttachedToTransactionFromDifferentFileUid()
        {
            var         proxy = new ActivityProxy();
            ActivityDto dto   = GetActivityDto();

            dto.Owner          = ApiUserEmailAddress;
            dto.AttachedToType = "Sale";
            dto.AttachedToUid  = 72599;            // this sale is not part of this file!!!

            try
            {
                proxy.Insert(dto);
            }
            catch (RestException ex)
            {
                StringAssert.Contains("Invalid attachedToUid", ex.Message);
            }
        }