예제 #1
0
 public void Ctors()
 {
     UnknownJobException ex = new UnknownJobException("UnknownJobExceptionTest-Ctors", "UnknownJob");
     Assert.That("UnknownJobExceptionTest-Ctors", Is.EqualTo(ex.MessageId));
     Assert.That("The job 'UnknownJob' from message with ID 'UnknownJobExceptionTest-Ctors' is unknown.",
         Is.EqualTo(ex.Message));
 }
예제 #2
0
        public void Ctors()
        {
            UnknownJobException ex = new UnknownJobException("UnknownJobExceptionTest-Ctors", "UnknownJob");

            Assert.That("UnknownJobExceptionTest-Ctors", Is.EqualTo(ex.MessageId));
            Assert.That("The job 'UnknownJob' from message with ID 'UnknownJobExceptionTest-Ctors' is unknown.",
                        Is.EqualTo(ex.Message));
        }
예제 #3
0
        public void SerializationDeserialization()
        {
            UnknownJobException ex = new UnknownJobException("UnknownJobExceptionTest-SerializationDeserialization", "UnknownJob");
            string serialized = JsonConvert.SerializeObject(ex);

            UnknownJobException ex2 = JsonConvert.DeserializeObject<UnknownJobException>(serialized);
            Assert.That(ex2.MessageId, Is.EqualTo("UnknownJobExceptionTest-SerializationDeserialization"));
            Assert.That(ex2.JobName, Is.EqualTo("UnknownJob"));
        }
예제 #4
0
        public void SerializationDeserialization()
        {
            UnknownJobException ex = new UnknownJobException("UnknownJobExceptionTest-SerializationDeserialization", "UnknownJob");
            string serialized      = JsonConvert.SerializeObject(ex);

            UnknownJobException ex2 = JsonConvert.DeserializeObject <UnknownJobException>(serialized);

            Assert.That(ex2.MessageId, Is.EqualTo("UnknownJobExceptionTest-SerializationDeserialization"));
            Assert.That(ex2.JobName, Is.EqualTo("UnknownJob"));
        }
예제 #5
0
        public Task ExecuteAsync(string jobName, int version, string json, CancellationToken cancellationToken)
        {
            if (!_jobDefinitionService.TryGetDefinition(jobName, version, out var jobDefinition))
            {
                throw UnknownJobException.With(jobName, version);
            }

            var executeCommandJob = (IJob)_jsonSerializer.Deserialize(json, jobDefinition.Type);

            return(executeCommandJob.ExecuteAsync(_serviceProvider, cancellationToken));
        }