コード例 #1
0
        public void Execute_UnknownInputType_ShouldReturnValidationIssue()
        {
            var stub = new SchedulerHostStub();

            var command = new AddTriggerCommand(() => stub.Value, new RegisteredInputType[0]);

            AddTriggerOutput result = (AddTriggerOutput)command.Execute(new AddTriggerInput
            {
                TriggerType = "Cron",
                JobDataMap  = new[]
                {
                    new JobDataItem
                    {
                        Key           = "CustomKey",
                        Value         = "CustomCode",
                        InputTypeCode = "custom"
                    },
                }
            });

            stub.AssertEmpty();

            result.AssertSuccessfull();

            Assert.That(result.ValidationErrors, Is.Not.Null);
            Assert.That(result.ValidationErrors["CustomKey"], Is.EqualTo("Unknown input type: custom"));
        }
コード例 #2
0
        public void Execute_ValidJobDataConversionIssue_ShouldReturnValidationIssue()
        {
            var converter = Substitute.For <IInputTypeConverter>();

            converter.Convert("CustomCode").Throws(new Exception("Custom conversion issue"));

            var stub = new SchedulerHostStub(new Type[0]);

            var command = new AddTriggerCommand(() => stub.Value, new[] { new RegisteredInputType(new InputType("custom"), converter) });

            AddTriggerOutput result = (AddTriggerOutput)command.Execute(new AddTriggerInput
            {
                TriggerType = "Cron",
                JobDataMap  = new[]
                {
                    new JobDataItem
                    {
                        Key           = "CustomKey",
                        Value         = "CustomCode",
                        InputTypeCode = "custom"
                    },
                }
            });

            stub.AssertEmpty();

            result.AssertSuccessfull();

            Assert.That(result.ValidationErrors, Is.Not.Null);
            Assert.That(result.ValidationErrors["CustomKey"], Is.EqualTo("Custom conversion issue"));
        }
コード例 #3
0
        public void Execute_UnknownTriggerType_ShouldReturnError()
        {
            var stub = new SchedulerHostStub();

            var command = new AddTriggerCommand(() => stub.Value, new RegisteredInputType[0]);

            AddTriggerOutput result = (AddTriggerOutput)command.Execute(new AddTriggerInput
            {
                TriggerType = "Unsupported"
            });

            Assert.That(result.Success, Is.False, "Success");
            Assert.That(result.ErrorMessage, Is.Not.Null);

            stub.AssertEmpty();
        }