예제 #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 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);
        }
예제 #5
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" });
        }
예제 #6
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");
        }