Exemplo n.º 1
0
        private async Task ValidateActionsAsync(
            IPolicyAgentDocumentForTenant doc,
            IList <IRepairTask> repairTasks,
            IList <JsonExpectedActions> idsAndExpectedActions)
        {
            Guid activityId = Guid.NewGuid();

            var reconciler = CreateReconciler();

            var coordinatorContext = new CoordinatorContext {
                Doc = doc
            };

            ActionHelper.CreateMappedWorkItems(doc.Jobs, repairTasks, coordinatorContext);

            await reconciler.ReconcileAsync(activityId, coordinatorContext).ConfigureAwait(false);

            var IdActionMap = GetReconciledActions(coordinatorContext);

            Assert.IsTrue(IdActionMap.Keys.SequenceEqual(idsAndExpectedActions.Select(e => e.Id)));

            foreach (var idAndExpectedAction in idsAndExpectedActions)
            {
                var actualAction = IdActionMap[idAndExpectedAction.Id];
                Assert.IsTrue(actualAction.SequenceEqual(idAndExpectedAction.Actions));
            }
        }
Exemplo n.º 2
0
        public async Task BasicTest1Async()
        {
            var activityId = Guid.NewGuid();
            var job        = TenantJobHelper.CreateNewTenantJob();
            var jobs       = new List <ITenantJob> {
                job
            };

            var doc = TenantJobHelper.CreateNewPolicyAgentDocumentForTenant(jobs, 1);

            var coordinatorContext = new CoordinatorContext {
                Doc = doc
            };

            ActionHelper.CreateMappedWorkItems(jobs, new List <IRepairTask>(), coordinatorContext);

            await CreateReconciler().ReconcileAsync(activityId, coordinatorContext).ConfigureAwait(false);

            Assert.AreEqual(coordinatorContext.MappedTenantJobs[job.Id].Actions.Count, 1);
            var action = coordinatorContext.MappedTenantJobs[job.Id].Actions[0];

            Assert.IsTrue(action is CreateInPreparingAction, "Verifying if new repair task is being created");
        }