Пример #1
0
        public void RunWorkflowForSqlImplWithServerUriAndRecordsetNameExpectedReturnsRecordsetAsDataTable()
        {
            var employees = _workflowResultXml.Elements("Employees").ToList();

            var workflows = new WorkflowsMock {
                ReturnXml = _workflowResultXml.ToString()
            };
            var result = workflows.RunWorkflowForSqlImpl(CreateSqlCtxMock(), TestServerUri, "Employees");

            Assert.IsNotNull(result);
            Assert.AreEqual(employees.Count, result.Rows.Count);

            // Verify that the DataTable was generated correctly
            foreach (var employee in employees)
            {
                var filter = new StringBuilder();
                foreach (var field in employee.Elements())
                {
                    filter.AppendFormat(" AND {0}='{1}'", field.Name.LocalName, field.Value);
                }
                filter.Remove(0, 5);
                var rows = result.Select(filter.ToString());
                Assert.AreEqual(1, rows.Length);
            }
        }
Пример #2
0
        public void RunWorkflowForSqlImplWithValidArgsExpectedInvokesSqlCtx()
        {
            var employees    = _workflowResultXml.Elements("Employees").ToList();
            var sendRowCount = 0;

            var ctx = new Mock <ISqlCtx>();

            ctx.Setup(c => c.SendStart(It.IsAny <DataTable>())).Verifiable();
            ctx.Setup(c => c.SendEnd()).Verifiable();
            ctx.Setup(c => c.SendRow(It.IsAny <SqlDataRecord>(), It.IsAny <object[]>())).Callback(() => sendRowCount++);

            var workflows = new WorkflowsMock {
                ReturnXml = _workflowResultXml.ToString()
            };

            workflows.RunWorkflowForSqlImpl(ctx.Object, TestServerUri, "Employees");

            ctx.VerifyAll();
            Assert.AreEqual(employees.Count, sendRowCount);
        }
Пример #3
0
        public void RunWorkflowForSqlImplWithServerUriAndNullRecordsetNameExpectedReturnsScalarsAsSingleRowInDataTable()
        {
            var workflows = new WorkflowsMock {
                ReturnXml = _workflowResultXml.ToString()
            };
            var result = workflows.RunWorkflowForSqlImpl(CreateSqlCtxMock(), TestServerUri, null);

            Assert.IsNotNull(result);

            var filter = new StringBuilder();

            foreach (var field in _workflowResultXml.Elements().Where(e => !e.HasElements))
            {
                filter.AppendFormat(" AND {0}='{1}'", field.Name.LocalName, field.Value);
            }
            filter.Remove(0, 5);
            var rows = result.Select(filter.ToString());

            Assert.AreEqual(1, rows.Length);
        }
        public void RunWorkflowForSqlImplWithValidArgsExpectedInvokesSqlCtx()
        {
            var employees = _workflowResultXml.Elements("Employees").ToList();
            var sendRowCount = 0;

            var ctx = new Mock<ISqlCtx>();
            ctx.Setup(c => c.SendStart(It.IsAny<DataTable>())).Verifiable();
            ctx.Setup(c => c.SendEnd()).Verifiable();
            ctx.Setup(c => c.SendRow(It.IsAny<SqlDataRecord>(), It.IsAny<object[]>())).Callback(() => sendRowCount++);

            var workflows = new WorkflowsMock { ReturnXml = _workflowResultXml.ToString() };
            workflows.RunWorkflowForSqlImpl(ctx.Object, TestServerUri, "Employees");

            ctx.VerifyAll();
            Assert.AreEqual(employees.Count, sendRowCount);
        }
        public void RunWorkflowForSqlImplWithServerUriAndNullRecordsetNameExpectedReturnsRecordsetsAsRowsInDataTable()
        {
            var workflows = new WorkflowsMock { ReturnXml = _workflowResultXml.ToString() };
            var result = workflows.RunWorkflowForSqlImpl(CreateSqlCtxMock(), TestServerUri, null);
            Assert.IsNotNull(result);

            foreach(var node in _workflowResultXml.Elements().Where(e => e.HasElements))
            {
                var filter = new StringBuilder();
                foreach(var field in node.Elements())
                {
                    filter.AppendFormat(" AND {0}{1}='{2}'", node.Name.LocalName, field.Name.LocalName, field.Value);
                }
                filter.Remove(0, 5);
                var rows = result.Select(filter.ToString());
                Assert.AreEqual(1, rows.Length);
            }
        }
        public void RunWorkflowForSqlImplWithServerUriAndRecordsetNameExpectedReturnsRecordsetAsDataTable()
        {
            var employees = _workflowResultXml.Elements("Employees").ToList();

            var workflows = new WorkflowsMock { ReturnXml = _workflowResultXml.ToString() };
            var result = workflows.RunWorkflowForSqlImpl(CreateSqlCtxMock(), TestServerUri, "Employees");
            Assert.IsNotNull(result);
            Assert.AreEqual(employees.Count, result.Rows.Count);

            // Verify that the DataTable was generated correctly
            foreach(var employee in employees)
            {
                var filter = new StringBuilder();
                foreach(var field in employee.Elements())
                {
                    filter.AppendFormat(" AND {0}='{1}'", field.Name.LocalName, field.Value);
                }
                filter.Remove(0, 5);
                var rows = result.Select(filter.ToString());
                Assert.AreEqual(1, rows.Length);
            }
        }