Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dotnet/src/dotnetcore/GxClasses/Domain/GXXmlReadWrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ internal void AppendNode(GXSOAPContext ctx, Node node, int extent)

char[] trimChars = { '\t', ' ' };

if (node.NodeType != ElementType) return;
if (node==null || node.NodeType != ElementType) return;
switch (node.NodeType)
{
case ElementType:
Expand Down Expand Up @@ -2131,6 +2131,10 @@ string removeUnallowedChars( string s)
public short WriteElement (string Name, string Value)
{
WriteStartElement(Name);
if (Value==null)
{
Value = string.Empty;
}
valueBuffer = Value;
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,10 @@ string removeUnallowedChars( string s)
public short WriteElement (string Name, string Value)
{
WriteStartElement(Name);
if (Value==null)
{
Value = string.Empty;
}
valueBuffer = Value;
return 0;
}
Expand All @@ -2154,7 +2158,7 @@ public short WriteElement (string Name, object Value)

public short WriteElement (string Name)
{
WriteElement (Name, "");
WriteElement (Name, string.Empty);
return 0;
}

Expand Down
49 changes: 49 additions & 0 deletions dotnet/test/DotNetUnitTest/Domain/XMLWriterTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GeneXus.Application;
using GeneXus.XML;
using Xunit;

namespace UnitTesting
{
public class XMLWriterTest : FileSystemTest
{
[Fact]
public void dfwpnumNullElementTest()
{
string content = dfwpnumTest(null, false);
Assert.Contains("<varchar xmlns=\"StorageExpiration\" />", content, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public void dfwpnumEmptyElementWithoutEndTest()
{
string content = dfwpnumTest("validValue", false);
Assert.Contains("<varchar xmlns=\"StorageExpiration\">validValue</varchar>", content, StringComparison.OrdinalIgnoreCase);
}
internal string dfwpnumTest(string varcharValue, bool closeElements)
{
GxContext context = new GxContext();
string fileName = Path.Combine(BaseDir, "dfwpnumTest.txt");
GXXMLWriter GXSoapXMLWriter = new GXXMLWriter(context.GetPhysicalPath());
GXSoapXMLWriter.Open(fileName);
GXSoapXMLWriter.WriteStartDocument("utf-8", 0);
GXSoapXMLWriter.WriteStartElement("SOAP-ENV:Envelope");
GXSoapXMLWriter.WriteElement("varchar", varcharValue);
GXSoapXMLWriter.WriteAttribute("xmlns", "StorageExpiration");
string sDateCnv = "0000-00-00";
GXSoapXMLWriter.WriteElement("date", sDateCnv);
GXSoapXMLWriter.WriteAttribute("xmlns", "StorageExpiration");
if (closeElements)
{
GXSoapXMLWriter.WriteEndElement();
}
GXSoapXMLWriter.Close();
return File.ReadAllText(fileName);
}

}
}