Esempio n. 1
0
        public void CanSyncRates()
        {
            var trace   = new Mock <ILoggingService>().Object;
            var service = new OrganisationServiceFactory().Create();
            var config  = service.GetFExConfiguration(new Guid("dcdda8b0-a34b-e711-811a-e0071b65dea1"),
                                                      ConfigAttribute.RunAttributes, trace);
            var repo = new AssertableDynamicsRepo(service);

            var job = new RateSyncJob(repo, service, config, new Mock <ILoggingService>().Object, Guid.NewGuid());

            job.Execute();

            Assert.AreEqual(repo.SaveCurrenciesCallCount, 1);
            Assert.That(config.LastSyncDate.Hour, Is.EqualTo(DateTime.UtcNow.Hour));
            Assert.That(config.LastSyncDate.Date, Is.EqualTo(DateTime.UtcNow.Date));
            Assert.That(config.LastRunStatus, Is.EqualTo(RunStatus.Success));
        }
        protected override void Execute(CodeActivityContext executionContext)
        {
            var tracingService = GetTraceService(executionContext);

            var workflowContext     = GetWorkflowContext(executionContext);
            var organisationService = GetOrganizationService(workflowContext.UserId, executionContext);
            var trace = new DynamicsLoggingService(tracingService, organisationService.GetUniqueOrganisationName(),
                                                   workflowContext.CorrelationId);
            var config = organisationService.GetFExConfiguration(workflowContext.PrimaryEntityId, ConfigAttribute.RunAttributes, trace);

            try
            {
                var rateSyncJob = new RateSyncJob(new DynamicsRepository(organisationService, trace), organisationService, config,
                                                  trace, workflowContext.CorrelationId);
                rateSyncJob.Execute();
            }
            catch (Exception exp)
            {
                var msg = "Error has Occured Running PerformRateSync Activity. Seting Last Run Status to Error and logging.";
                HandleException(exp, msg, config, organisationService, trace);
            }
        }