// ReSharper disable InconsistentNaming public void DbService_ToXml_CorrectXml() // ReSharper restore InconsistentNaming { // ReSharper disable InconsistentNaming const string xmlDataString = @"<Service ID=""af8d2d38-22b5-4599-8357-adce196beb83"" Name=""TravsTestService"" ResourceType=""DbService"" IsValid=""true""> <Actions> <Action Name=""dbo.InsertDummyUser"" Type=""InvokeStoredProc"" SourceID=""ebba47dc-e5d4-4303-a203-09e2e9761d16"" SourceName=""testingDBSrc"" ExecuteAction=""dbo.InsertDummyUser"" SourceMethod=""dbo.InsertDummyUser""> <Inputs> <Input Name=""fname"" Source=""fname"" EmptyToNull=""false"" DefaultValue="""" NativeType=""System.Object"" /> <Input Name=""lname"" Source=""lname"" EmptyToNull=""false"" DefaultValue="""" NativeType=""System.Object"" /> <Input Name=""username"" Source=""username"" EmptyToNull=""false"" DefaultValue="""" NativeType=""System.Object"" /> <Input Name=""password"" Source=""password"" EmptyToNull=""false"" DefaultValue="""" NativeType=""System.Object"" /> <Input Name=""lastAccessDate"" Source=""lastAccessDate"" EmptyToNull=""false"" DefaultValue="""" NativeType=""System.Object"" /> </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>TravsTestService</DisplayName> <Category>WEBPART_WIZARDS</Category> <AuthorRoles></AuthorRoles> <ErrorMessages /> </Service>"; // ReSharper restore InconsistentNaming XElement testElm = XElement.Parse(xmlDataString); DbService dbService = new DbService(testElm); XElement returnedXelm = dbService.ToXml(); string actual = returnedXelm.ToString(); Assert.AreEqual(xmlDataString, actual); }
// 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()); }