Пример #1
0
        public InvokeWebActionResult StartProcessAction()
        {
            _totalExecutionTimeStopWatch = Stopwatch.StartNew();

            _result           = new InvokeWebActionResult();
            _result.StartDate = DateTime.Now;

            ClientContext previousContext = PnPConnection.CurrentConnection.Context;

            UpdatePropertiesToLoad();

            List <Web> webs;

            if (_subWebs)
            {
                webs = GetSubWebs(_webs.ToList());
            }
            else
            {
                webs = _webs.ToList();
            }

            if (!_skipCounting)
            {
                CountItems(webs);
            }

            ProcessAction(webs);

            UpdateResult();

            //Reset context to where the user were before.
            PnPConnection.CurrentConnection.Context = previousContext;

            return(_result);
        }
        private void AssertInvokeActionResult(InvokeWebActionResult result,
            int? processedWebCount = null,
            int? processedPostWebCount = null,
            int? processedListCount = null,
            int? processedPostListCount = null,
            int? processedListItemCount = null,
            int? processedPostListItemCount = null)
        {
            Assert.IsNotNull(result, "InvokeActionResult is null");

            if (processedWebCount.HasValue)
            {
                Assert.AreEqual(processedWebCount.Value, result.ProcessedWebCount, "Total proccessed web count does not match");

                if(result.AverageWebTime.HasValue)
                    Assert.IsTrue(result.AverageWebTime > 0, "Average web time is 0");
            }

            if (processedPostWebCount.HasValue)
            {
                Assert.AreEqual(processedPostWebCount.Value, result.ProcessedPostWebCount, "Total proccessed web count does not match");

                if (result.AveragePostWebTime.HasValue)
                    Assert.IsTrue(result.AveragePostWebTime > 0, "Average web time is 0");
            }

            if (processedListCount.HasValue)
            {
                Assert.AreEqual(processedListCount.Value, result.ProcessedListCount, "Total proccessed list count does not match");

                if (result.AverageListTime.HasValue)
                    Assert.IsTrue(result.AverageListTime > 0, "Average list time is 0");
            }

            if (processedPostListCount.HasValue)
            {
                Assert.AreEqual(processedPostListCount.Value, result.ProcessedPostListCount, "Total proccessed list count does not match");

                if (result.AveragePostListTime.HasValue)
                    Assert.IsTrue(result.AveragePostListTime > 0, "Average list time is 0");
            }

            if (processedListItemCount.HasValue)
            {
                Assert.AreEqual(processedListItemCount.Value, result.ProcessedListItemCount, "Total proccessed list item count does not match");

                if (result.AverageListItemTime.HasValue)
                    Assert.IsTrue(result.AverageListItemTime > 0, "Average list item time is 0");
            }

            Assert.IsTrue(result.StartDate >= DateTime.Today, "Incorrect start date");
            Assert.IsTrue(result.EndDate >= DateTime.Today, "Incorrect end date");
            Assert.IsTrue(result.EndDate > result.StartDate, "End date is not greater than start date");
        }