Exemple #1
0
        private IEsbExecutionContainer GenerateContainer(ServiceAction serviceAction, IDSFDataObject dataObj, IWorkspace theWorkspace)
        {
            // set the ID for later use ;)
            dataObj.WorkspaceID = _workspace.ID;

            IEsbExecutionContainer result = null;

            if (dataObj.IsServiceTestExecution)
            {
                result = new ServiceTestExecutionContainer(serviceAction, dataObj, _workspace, _esbChannel, _request);
            }
            else
            {
                switch (serviceAction.ActionType)
                {
                case enActionType.InvokeManagementDynamicService:
                    result = new InternalServiceContainer(serviceAction, dataObj, theWorkspace, _esbChannel, _request);
                    break;

                case enActionType.InvokeWebService:
                    result = new WebServiceContainer(serviceAction, dataObj, theWorkspace, _esbChannel);
                    break;

                case enActionType.Workflow:
                    result = new PerfmonExecutionContainer(new WfExecutionContainer(serviceAction, dataObj, theWorkspace, _esbChannel));
                    break;

                case enActionType.RemoteService:
                    result = new RemoteWorkflowExecutionContainer(serviceAction, dataObj, null, _esbChannel);
                    break;
                }
            }
            return(result);
        }
Exemple #2
0
        public void GetTestRunResults_Given_ThereIsNoError_And_EnvironmentHasNoErrorSetsTest_ToPass()
        {
            //------------Setup for test-------------------------
            var          resourceId    = Guid.NewGuid();
            const string Datalist      = "<DataList><scalar1 ColumnIODirection=\"Input\"/><persistantscalar ColumnIODirection=\"Input\"/><rs><f1 ColumnIODirection=\"Input\"/><f2 ColumnIODirection=\"Input\"/></rs><recset><field1/><field2/></recset></DataList>";
            var          serviceAction = new ServiceAction
            {
                DataListSpecification = new StringBuilder(Datalist),
                Service = new DynamicService {
                    ID = resourceId
                }
            };
            var dsfObj = new Mock <IDSFDataObject>();

            dsfObj.SetupProperty(o => o.ResourceID);
            const string TestName = "test1";

            dsfObj.Setup(o => o.TestName).Returns(TestName);
            dsfObj.Setup(o => o.StopExecution).Returns(true);
            dsfObj.Setup(o => o.Environment).Returns(new ExecutionEnvironment());
            dsfObj.Setup(o => o.Environment.Eval(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), false))
            .Returns(CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.NewDataString("Args")));
            dsfObj.Setup(o => o.Environment.AllErrors).Returns(new HashSet <string>());
            dsfObj.Setup(o => o.IsDebugMode()).Returns(true);
            dsfObj.Setup(o => o.Environment.HasErrors()).Returns(true);
            dsfObj.Setup(o => o.Environment.FetchErrors()).Returns("Failed: The user running the test is not authorized to execute resource .");
            var fetch       = JsonResource.Fetch("UnAuthorizedHelloWorld");
            var s           = new Dev2JsonSerializer();
            var testModelTO = s.Deserialize <ServiceTestModelTO>(fetch);

            var cataLog = new Mock <ITestCatalog>();

            cataLog.Setup(cat => cat.SaveTest(It.IsAny <Guid>(), It.IsAny <IServiceTestModelTO>())).Verifiable();
            cataLog.Setup(cat => cat.FetchTest(resourceId, TestName)).Returns(testModelTO);
            var resourceCat = new Mock <IResourceCatalog>();
            var activity    = new Mock <IDev2Activity>();

            resourceCat.Setup(catalog => catalog.Parse(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(activity.Object);
            var workSpace                     = new Mock <IWorkspace>();
            var channel                       = new Mock <IEsbChannel>();
            var esbExecuteRequest             = new EsbExecuteRequest();
            var serviceTestExecutionContainer = new ServiceTestExecutionContainer(serviceAction, dsfObj.Object, workSpace.Object, channel.Object, esbExecuteRequest);
            var testObj                       = new PrivateObject(serviceTestExecutionContainer);
            var output = new Mock <IServiceTestOutput>();

            output.Setup(testOutput => testOutput.AssertOp).Returns("There is No Error");
            //------------Execute Test---------------------------
            var invoke         = testObj.Invoke("GetTestRunResults", dsfObj.Object, output.Object, null);
            var testRunResults = invoke as IEnumerable <TestRunResult>;
            //------------Assert Results-------------------------
            var firstOrDefault = testRunResults?.FirstOrDefault();

            Assert.IsTrue(firstOrDefault != null && firstOrDefault.RunTestResult == RunResult.TestPassed);
        }
Exemple #3
0
        public void UpdateTestWithStepValues_Sets_The_Correct_FailureMessage()
        {
            //------------Setup for test-------------------------
            var          resourceId    = Guid.NewGuid();
            const string Datalist      = "<DataList><scalar1 ColumnIODirection=\"Input\"/><persistantscalar ColumnIODirection=\"Input\"/><rs><f1 ColumnIODirection=\"Input\"/><f2 ColumnIODirection=\"Input\"/></rs><recset><field1/><field2/></recset></DataList>";
            var          serviceAction = new ServiceAction
            {
                DataListSpecification = new StringBuilder(Datalist),
                Service = new DynamicService {
                    ID = resourceId
                }
            };
            var dsfObj = new Mock <IDSFDataObject>();

            dsfObj.SetupProperty(o => o.ResourceID);
            const string TestName = "test1";

            dsfObj.Setup(o => o.TestName).Returns(TestName);
            dsfObj.Setup(o => o.StopExecution).Returns(true);
            dsfObj.Setup(o => o.Environment).Returns(new ExecutionEnvironment());
            dsfObj.Setup(o => o.Environment.Eval(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), false))
            .Returns(CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.NewDataString("Args")));
            dsfObj.Setup(o => o.Environment.AllErrors).Returns(new HashSet <string>());
            dsfObj.Setup(o => o.IsDebugMode()).Returns(true);
            dsfObj.Setup(o => o.Environment.HasErrors()).Returns(true);
            dsfObj.Setup(o => o.Environment.FetchErrors()).Returns("Failed: The user running the test is not authorized to execute resource .");
            var fetch       = JsonResource.Fetch("UnAuthorizedHelloWorld");
            var s           = new Dev2JsonSerializer();
            var testModelTO = s.Deserialize <ServiceTestModelTO>(fetch);

            var cataLog = new Mock <ITestCatalog>();

            cataLog.Setup(cat => cat.SaveTest(It.IsAny <Guid>(), It.IsAny <IServiceTestModelTO>())).Verifiable();
            cataLog.Setup(cat => cat.FetchTest(resourceId, TestName)).Returns(testModelTO);
            var resourceCat = new Mock <IResourceCatalog>();
            var activity    = new Mock <IDev2Activity>();

            resourceCat.Setup(catalog => catalog.Parse(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(activity.Object);
            var workSpace                     = new Mock <IWorkspace>();
            var channel                       = new Mock <IEsbChannel>();
            var esbExecuteRequest             = new EsbExecuteRequest();
            var serviceTestExecutionContainer = new ServiceTestExecutionContainer(serviceAction, dsfObj.Object, workSpace.Object, channel.Object, esbExecuteRequest);
            var testObj                       = new PrivateType(serviceTestExecutionContainer.GetType());
            var test = SetupServiceTestSteps();

            testObj.InvokeStatic("UpdateTestWithStepValues", test.Object);
            //------------Execute Test---------------------------
            var expectedMessage = @"Failed Step:  
Message: Test Failed because of some reasons
Failed Output For Variable:  
Message: This test has failed
Invalid Output for Variable: 
Message: This test is invalid
Pending Output for Variable: 
Test Failed because of some reasons
";

            //------------Assert Results-------------------------
            test.VerifySet(to =>
            {
                to.FailureMessage = expectedMessage.ToString();
            }, Times.AtLeastOnce);
        }