Пример #1
0
        public void Load()
        {
            using (var context = CreateMethodContext())
            {
                // Create data log record and save
                var dataLog = new DataLog();
                dataLog.LogName = "SampleLog";
                context.SaveOne(dataLog);

                // Create queue record and save, then get its id
                var queue = new JobQueue();
                queue.JobQueueName = "SampleQueue";
                queue.Log          = dataLog.ToKey();
                context.SaveOne(queue, context.DataSet);
                var queueId = queue.Id;

                // Create sample record
                var sampleRecord = new SampleRecord();
                sampleRecord.SampleName = "SampleName";
                context.SaveOne(sampleRecord);

                // Create job record and save, then get its id
                var job = new Job();
                job.Queue          = queue.ToKey();
                job.CollectionName = DataTypeInfo.GetOrCreate <SampleRecord>().GetCollectionName();
                job.RecordId       = sampleRecord.Id;
                job.MethodName     = "SampleMethod";
                context.SaveOne(job);
                var jobId = job.Id;

                // Load the records back
                var queueKey    = queue.ToKey();
                var loadedQueue = context.Load(queueKey);
                var jobKey      = new JobKey {
                    Id = jobId
                };
                var loadedJob = context.Load(jobKey);

                // Check that TemporalId based key works correctly
                Assert.True(loadedJob.Queue.Value == loadedQueue.ToKey().Value);

                // Run the job
                // TODO - incomment when implemented
                // loadedJob.Run();

                context.Log.Verify("Completed");
            }
        }