Esempio n. 1
0
        public void UpdateActivity()
        {
            var proxy    = new ActivityProxy();
            var activity = proxy.GetActivity(_testActivityToBeUpdated);

            var uniqueId       = Guid.NewGuid().ToString().Substring(0, 5);
            var title          = "Test activity " + uniqueId;
            var details        = "Details of test activity " + uniqueId;
            var done           = !activity.DataObject.Done;
            var due            = activity.DataObject.Due.AddDays(1);
            var ownerEmail     = string.IsNullOrWhiteSpace(activity.DataObject.OwnerEmail) ? TestConfig.TestUser : null;
            var attachedToType = string.IsNullOrWhiteSpace(activity.DataObject.AttachedToType) ? null : "Sale";
            int?attachedToId   = null;

            if (activity.DataObject.AttachedToId != null && activity.DataObject.AttachedToId > 0)
            {
                attachedToId = _saleInvoiceTranId;
            }

            var updateActivty = new ActivityDetail
            {
                Title          = title,
                Details        = details,
                Done           = done,
                Due            = due,
                OwnerEmail     = ownerEmail,
                AttachedToType = attachedToType,
                AttachedToId   = attachedToId,
                LastUpdatedId  = activity.DataObject.LastUpdatedId
            };

            var updateResponse = proxy.UpdateActivity(_testActivityToBeUpdated, updateActivty);

            Assert.True(updateResponse.IsSuccessfull, "Call to UpdateActivity was not successful");
            Assert.True(updateResponse.DataObject != null, "Call to InsertActivity returned no data");
            Assert.Equal(_testActivityToBeUpdated, updateResponse.DataObject.UpdatedActivityId);

            var activityGet = proxy.GetActivity(_testActivityToBeUpdated);

            Assert.True(activityGet.DataObject != null, "No row returned from Get after update.");

            VerifyDetailsAreSame(updateActivty, activityGet.DataObject);
        }