From ddee6106d9ba0c072d4b6cf2ef4890bbc5927d1c Mon Sep 17 00:00:00 2001 From: Simon Gockner Date: Thu, 13 Feb 2020 15:38:49 +0100 Subject: [PATCH] #11: removeValue can handle enumerables now --- GBase/DataHandling/XmlDataHandler.cs | 8 +++++++- Test.GBase/DataHandling/XmlDataHandlerTest.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/GBase/DataHandling/XmlDataHandler.cs b/GBase/DataHandling/XmlDataHandler.cs index d8d76bc..6c79de3 100644 --- a/GBase/DataHandling/XmlDataHandler.cs +++ b/GBase/DataHandling/XmlDataHandler.cs @@ -122,8 +122,14 @@ namespace GBase.DataHandling if (value == null) return; + string valueString; + if (typeof(TProperty) != typeof(string) && value is IEnumerable enumerable) + valueString = enumerable.ToGBaseString(); + else + valueString = value.ToString(); + await _cache.TryRemoveValue(propertyName, value); - await _xmlDataWriter.Remove(propertyName, value.ToString()); + await _xmlDataWriter.Remove(propertyName, valueString); } /// diff --git a/Test.GBase/DataHandling/XmlDataHandlerTest.cs b/Test.GBase/DataHandling/XmlDataHandlerTest.cs index 89881e7..62782f2 100644 --- a/Test.GBase/DataHandling/XmlDataHandlerTest.cs +++ b/Test.GBase/DataHandling/XmlDataHandlerTest.cs @@ -238,7 +238,7 @@ namespace Test.GBase.DataHandling await xmlDataHandler.RemoveValue>("property", stringList); xmlDataHandlerCacheMock.Verify(c => c.TryRemoveValue>("property", stringList), Times.Once); - xmlDataWriterMock.Verify(w => w.Remove>("property", $"{stringList[0]}, {stringList[1]}, {stringList[2]}"), Times.Once); + xmlDataWriterMock.Verify(w => w.Remove>("property", $"{stringList[0]},{stringList[1]},{stringList[2]}"), Times.Once); } [Test]