// ReSharper disable InconsistentNaming public void DbService_ToXml_WhenRecordSetHasBlankFields_ExpectNotPartOfOutputDescription() // ReSharper restore InconsistentNaming { //------------Setup for test-------------------------- var dbService = new DbService(); var dbSource = new DbSource { ResourceName = "Source" }; var resourceId = Guid.NewGuid(); dbSource.ResourceID = resourceId; dbService.Source = dbSource; var serviceMethod = new ServiceMethod { Name = "Method" }; dbService.Method = serviceMethod; var recordset = new Recordset { Name = "SomeRecSet" }; var recordsetField = new RecordsetField { Alias = "SomeAlias", Name = "" }; recordset.Fields.Add(recordsetField); dbService.Recordset = recordset; // ReSharper disable InconsistentNaming const string expected = @"<Service ID=""00000000-0000-0000-0000-000000000000"" Name="""" ResourceType=""DbService"" IsValid=""false""> <Actions> <Action Name=""SomeRecSet"" Type=""InvokeStoredProc"" SourceID=""{0}"" SourceName=""Source"" ExecuteAction="""" SourceMethod=""Method""> <Inputs /> <Outputs /> <OutputDescription><![CDATA[<z:anyType xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:d1p1=""http://schemas.datacontract.org/2004/07/Unlimited.Framework.Converters.Graph.Ouput"" i:type=""d1p1:OutputDescription"" xmlns:z=""http://schemas.microsoft.com/2003/10/Serialization/""><d1p1:DataSourceShapes xmlns:d2p1=""http://schemas.microsoft.com/2003/10/Serialization/Arrays""><d2p1:anyType i:type=""d1p1:DataSourceShape""><d1p1:_x003C_Paths_x003E_k__BackingField /></d2p1:anyType></d1p1:DataSourceShapes><d1p1:Format>ShapedXML</d1p1:Format></z:anyType>]]></OutputDescription> </Action> </Actions> <AuthorRoles /> <Comment /> <Tags /> <HelpLink /> <UnitTestTargetWorkflowService /> <BizRule /> <WorkflowActivityDef /> <XamlDefinition /> <DataList /> <TypeOf>InvokeStoredProc</TypeOf> <DisplayName></DisplayName> <Category></Category> <AuthorRoles></AuthorRoles> <ErrorMessages /> </Service>"; // ReSharper restore InconsistentNaming //------------Execute Test--------------------------- var xElement = dbService.ToXml(); //------------Assert Results------------------------- Assert.AreEqual(string.Format(expected, resourceId), xElement.ToString()); }
public void MySqlMapDbOutputs(IOutputDescription outputDescription, ref DbService theService, bool addFields) { // only fetch paths with valid data to map ;) var outputsToMap = outputDescription.DataSourceShapes[0].Paths.Where(p => !string.IsNullOrEmpty(p.DisplayPath) && p.DisplayPath != "DocumentElement"); var rsFields = new List <RecordsetField>(theService.Recordset.Fields); #pragma warning disable 219 int recordsetIndex = 0; #pragma warning restore 219 foreach (var path in outputsToMap) { // Remove bogus names and dots var name = path.DisplayPath.Replace("NewDataSet", "").Replace(".Table.", "").Replace("DocumentElement", ""); var alias = path.DisplayPath.Replace("NewDataSet", "").Replace(".Table.", "").Replace(".", "").Replace("DocumentElement", ""); var idx = name.IndexOf("()", StringComparison.InvariantCultureIgnoreCase); if (idx >= 0) { name = name.Remove(0, idx + 3); } idx = alias.IndexOf("()", StringComparison.InvariantCultureIgnoreCase); if (idx >= 0) { alias = alias.Remove(0, idx + 2); } var field = new RecordsetField { Name = name, Alias = string.IsNullOrEmpty(path.OutputExpression) ? alias : path.OutputExpression, Path = path }; RecordsetField rsField; if (!addFields && (rsField = rsFields.FirstOrDefault(f => f.Path != null ? f.Path.ActualPath == path.ActualPath : f.Name == field.Name)) != null) { field.Alias = rsField.Alias; } theService.Recordset.Fields.Add(field); // 2013.12.11 - COMMUNITY BUG - 341463 - data with empty cells displays incorrectly var data = path.SampleData.Split(new[] { GlobalConstants.AnytingToXmlCommaToken }, StringSplitOptions.None); var recordIndex = 0; foreach (var item in data) { theService.Recordset.SetValue(recordIndex, recordsetIndex, item); recordIndex++; } recordsetIndex++; } }
public void ThenTheMappingShouldContainThePrimitiveArray() { var webService = ScenarioContext.Current.Get <ServiceModel.Data.WebService>("WebService"); RecordsetList recordsetList = webService.Recordsets; Assert.IsNotNull(recordsetList); var departmentsRecordSet = recordsetList.Find(recordset => recordset.Name == "Departments"); Assert.IsNotNull(departmentsRecordSet); List <RecordsetField> departmentFields = departmentsRecordSet.Fields; Assert.AreEqual(2, departmentFields.Count); RecordsetField departmentNameField = departmentFields.Find(field => field.Name == "Name"); Assert.IsNotNull(departmentNameField); RecordsetField departmentAreasField = departmentFields.Find(field => field.Name == "Areas"); Assert.IsNotNull(departmentAreasField); }
public void WebServiceToXmlExpectedSerializesProperties() { var expected = new WebService { Source = new WebSource { ResourceID = Guid.NewGuid(), ResourceName = "TestWebSource", }, RequestUrl = "pqr", RequestMethod = WebRequestMethod.Get, RequestHeaders = "Content-Type: text/xml", RequestBody = "abc", RequestResponse = "xyz", JsonPath = "$.somepath" }; #region setup method parameters expected.Method.Parameters.AddRange( new[] { new MethodParameter { Name = "Param1", DefaultValue = "123" }, new MethodParameter { Name = "Param2", DefaultValue = "456" } }); #endregion #region setup rs1 var rs1 = new Recordset { Name = "Recordset1()" }; rs1.Fields.AddRange(new[] { new RecordsetField { Name = "Field1", Alias = "Alias1", RecordsetAlias = "RecAlias1()" }, new RecordsetField { Name = "Field2", Alias = "Alias2", RecordsetAlias = "RecAlias1()" } }); expected.Recordsets.Add(rs1); #endregion #region setup rs2 var rs2 = new Recordset { Name = "Recordset2()" }; rs2.Fields.AddRange(new[] { new RecordsetField { Name = "Field3", Alias = "Alias3" }, new RecordsetField { Name = "Field4", Alias = "Alias4" } }); expected.Recordsets.Add(rs2); #endregion var xml = expected.ToXml(); var actual = new WebService(xml); Assert.AreEqual(expected.Source.ResourceType, actual.Source.ResourceType); Assert.AreEqual(expected.Source.ResourceID, actual.Source.ResourceID); Assert.AreEqual(expected.Source.ResourceName, actual.Source.ResourceName); Assert.AreEqual(expected.ResourceType, actual.ResourceType); Assert.AreEqual(expected.RequestUrl, actual.RequestUrl); Assert.AreEqual(expected.RequestMethod, actual.RequestMethod); Assert.AreEqual(expected.RequestHeaders, actual.RequestHeaders); Assert.AreEqual(expected.RequestBody, actual.RequestBody); Assert.AreEqual(expected.JsonPath, actual.JsonPath); Assert.IsNull(actual.RequestResponse); foreach (var expectedParameter in expected.Method.Parameters) { MethodParameter parameter = expectedParameter; var actualParameter = actual.Method.Parameters.First(p => p.Name == parameter.Name); Assert.AreEqual(expectedParameter.DefaultValue, actualParameter.DefaultValue); } foreach (var expectedRecordset in expected.Recordsets) { // expect actual to have removed recordset notation ()... Recordset recordset = expectedRecordset; var actualRecordset = actual.Recordsets.First(rs => rs.Name == recordset.Name.Replace("()", "")); foreach (var expectedField in expectedRecordset.Fields) { RecordsetField field = expectedField; var actualField = actualRecordset.Fields.First(f => f.Name == field.Name); Assert.AreEqual(expectedField.Alias, actualField.Alias); // expect actual to have removed recordset notation ()... var expectedRecordsetAlias = string.IsNullOrEmpty(expectedField.RecordsetAlias) ? string.Empty : expectedField.RecordsetAlias.Replace("()", ""); Assert.AreEqual(expectedRecordsetAlias, actualField.RecordsetAlias); } } }