Exemplo n.º 1
0
        public void DsfNativeActivity_ExecuteTool_TestErrors_TestExecution()
        {
            CurrentDl = "<ADL><result></result></ADL>";
            TestData  = "<root><ADL><result></result></ADL></root>";
            var act = new TestNativeActivity(false, "bob");

            act.IsEndedOnError  = true;
            act.OnErrorVariable = "[[Error]]";
            act.OnErrorWorkflow = "[[OnErrorWorkflow]]";
            TestStartNode       = new FlowStep
            {
                Action = act
            };
            var executionEnvironment = new ExecutionEnvironment();

            executionEnvironment.AddError("First Error");
            var dataObjectMock = new Mock <IDSFDataObject>();
            var channel        = new Mock <IEsbChannel>();
            var errorResultTO  = new ErrorResultTO();

            errorResultTO.AddError("asdasd");
            channel.Setup(o => o.ExecuteLogErrorRequest(dataObjectMock.Object, It.IsAny <Guid>(), It.IsAny <string>(), out errorResultTO, 0));
            dataObjectMock.Setup(o => o.Environment).Returns(executionEnvironment);
            dataObjectMock.Setup(o => o.IsDebugMode()).Returns(true);
            dataObjectMock.Setup(o => o.EsbChannel).Returns(channel.Object);
            var dataObject = act.Execute(dataObjectMock.Object, 0);

            Assert.AreEqual("First Error" + Environment.NewLine + "asdasd", dataObjectMock.Object.Environment.FetchErrors());
        }
Exemplo n.º 2
0
        public void DsfNativeActivity_ExecuteTool_NoTestStepOutputs_TestExecution()
        {
            var dataObject = new DsfDataObject("<Datalist></Datalist>", Guid.NewGuid())
            {
                ServerID               = Guid.NewGuid(),
                IsDebug                = true,
                ForEachNestingLevel    = 0,
                IsServiceTestExecution = true
            };

            var act = new TestNativeActivity(false, "bob");

            var serviceTestModelTO = new ServiceTestModelTO
            {
                TestSteps = new List <IServiceTestStep>
                {
                    new ServiceTestStepTO
                    {
                        UniqueId    = Guid.Parse(act.UniqueID),
                        Type        = StepType.Assert,
                        StepOutputs = new ObservableCollection <IServiceTestOutput>
                        {
                        }
                    }
                }
            };

            dataObject.ServiceTest = serviceTestModelTO;
            act.Execute(dataObject, 0);
            act.DispatchDebugState(dataObject, StateType.After, 0);

            Assert.AreEqual(RunResult.TestPending, serviceTestModelTO.TestSteps[0].Result.RunTestResult);
            Assert.IsFalse(dataObject.StopExecution);
        }
Exemplo n.º 3
0
        public void DsfNativeActivity_ExecuteTool_Errors_PerformsErrorHandling()
        {
            var dataObject = new DsfDataObject("<Datalist></Datalist>", Guid.NewGuid())
            {
                ServerID               = Guid.NewGuid(),
                IsDebug                = false,
                ForEachNestingLevel    = 0,
                IsServiceTestExecution = true
            };

            var act = new TestNativeActivity(false, "bob");

            act.IsEndedOnError  = true;
            act.OnErrorVariable = "[[Error]]";
            dataObject.Environment.AddError("There is an error");
            ExecutableServiceRepository.Instance.Add(new TestExecutionService
            {
                WorkspaceID = dataObject.WorkspaceID,
                ID          = dataObject.ResourceID
            });
            act.Execute(dataObject, 0);

            var warewolfEvalResult = dataObject.Environment.Eval("[[Error]]", 0) as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult;

            Assert.IsNotNull(warewolfEvalResult);
            var errorMessage = warewolfEvalResult.Item.ToString();

            Assert.IsTrue(dataObject.StopExecution);
            Assert.AreEqual("There is an error", errorMessage);
        }
Exemplo n.º 4
0
        public void DsfNativeActivity_ExecuteTool_Errors_PerformsErrorHandling_ShouldNotThrow()
        {
            var dataObject = new DsfDataObject("<Datalist></Datalist>", Guid.NewGuid())
            {
                ServerID               = Guid.NewGuid(),
                IsDebug                = false,
                ForEachNestingLevel    = 0,
                IsServiceTestExecution = true
            };

            var act = new TestNativeActivity(false, "bob");

            act.IsEndedOnError  = true;
            act.OnErrorVariable = "[[Error().Message]]";
            dataObject.Environment.AddError("There is an error with special character: { special will Parse }");

            var result = act.Execute(dataObject, 0);

            var warewolfEvalResult = dataObject.Environment.Eval("[[Error(*).Message]]", 0) as CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult;

            Assert.IsNotNull(warewolfEvalResult);
            var errorMessage = warewolfEvalResult.Item[0].ToString();

            Assert.IsTrue(dataObject.StopExecution);
            Assert.AreEqual("There is an error with special character: { special will Parse }", errorMessage);
        }
Exemplo n.º 5
0
        public void DsfNativeActivity_ExecuteTool_DebugFalse_TestExecution()
        {
            var dataObject = new DsfDataObject("<Datalist></Datalist>", Guid.NewGuid())
            {
                ServerID               = Guid.NewGuid(),
                IsDebug                = false,
                ForEachNestingLevel    = 0,
                IsServiceTestExecution = true
            };

            var act = new TestNativeActivity(false, "bob");

            var serviceTestModelTO = new ServiceTestModelTO
            {
                TestSteps = new List <IServiceTestStep>
                {
                    new ServiceTestStepTO
                    {
                        UniqueId    = Guid.Parse(act.UniqueID),
                        Type        = StepType.Assert,
                        StepOutputs = new ObservableCollection <IServiceTestOutput>
                        {
                            new ServiceTestOutputTO
                            {
                                AssertOp = "=",
                                Value    = "Bob",
                                Variable = "[[var]]"
                            }
                        }
                    }
                }
            };

            dataObject.ServiceTest = serviceTestModelTO;

            act.Execute(dataObject, 0);

            Assert.AreEqual(RunResult.TestFailed, serviceTestModelTO.Result.RunTestResult);
            Assert.IsTrue(dataObject.StopExecution);
        }
Exemplo n.º 6
0
        public void DsfNativeActivity_ExecuteTool_Errors_PerformsErrorHandling_ShouldReturnErrors()
        {
            var dataObject = new DsfDataObject("<Datalist></Datalist>", Guid.NewGuid())
            {
                ServerID               = Guid.NewGuid(),
                IsDebug                = false,
                ForEachNestingLevel    = 0,
                IsServiceTestExecution = true
            };

            var act = new TestNativeActivity(false, "bob");

            act.IsEndedOnError  = true;
            act.OnErrorVariable = "[[Error().Massage]]";
            dataObject.Environment.AddError("There is an error with special character: [[special.willNotParse)");

            _ = act.Execute(dataObject, 0);

            var errors = dataObject.Environment.Errors;

            Assert.AreEqual("There is an error with special character: [[special.willNotParse)", errors.First(), "Warewolf error cannot have special characters");
            Assert.AreEqual("parse error: { Error().Massage }", errors.Last());
        }