diff --git a/test/Spring/Spring.Core.Tests/StringResource.cs b/src/Spring/Spring.Core/Core/IO/StringResource.cs
similarity index 83%
rename from test/Spring/Spring.Core.Tests/StringResource.cs
rename to src/Spring/Spring.Core/Core/IO/StringResource.cs
index 8f717af2..0baaf7d1 100644
--- a/test/Spring/Spring.Core.Tests/StringResource.cs
+++ b/src/Spring/Spring.Core/Core/IO/StringResource.cs
@@ -28,10 +28,10 @@ using Spring.Util;
#endregion
-namespace Spring
+namespace Spring.Core.IO
{
///
- /// A adapter implementation encapsulating a simply string.
+ /// A adapter implementation encapsulating a simple string.
///
/// Erich Eichinger
public class StringResource : AbstractResource
@@ -111,5 +111,21 @@ namespace Spring
{
get { return true; }
}
+
+ ///
+ /// Gets the encoding used to create a byte stream of the string.
+ ///
+ public Encoding Encoding
+ {
+ get { return _encoding; }
+ }
+
+ ///
+ /// Gets the content encapsulated by this .
+ ///
+ public string Content
+ {
+ get { return _content; }
+ }
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Spring.Core.2003.csproj b/src/Spring/Spring.Core/Spring.Core.2003.csproj
index 050dc9b6..125c2e2c 100644
--- a/src/Spring/Spring.Core/Spring.Core.2003.csproj
+++ b/src/Spring/Spring.Core/Spring.Core.2003.csproj
@@ -622,6 +622,11 @@
SubType = "Code"
BuildAction = "Compile"
/>
+
+
diff --git a/test/Spring/Spring.Core.Tests/Core/IO/StringResourceTests.cs b/test/Spring/Spring.Core.Tests/Core/IO/StringResourceTests.cs
new file mode 100644
index 00000000..652fc448
--- /dev/null
+++ b/test/Spring/Spring.Core.Tests/Core/IO/StringResourceTests.cs
@@ -0,0 +1,106 @@
+#region License
+
+/*
+ * Copyright © 2002-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#endregion
+
+#region Imports
+
+using System;
+using System.IO;
+using System.Text;
+using NUnit.Framework;
+
+#endregion
+
+namespace Spring.Core.IO
+{
+ ///
+ ///
+ ///
+ /// Erich Eichinger
+ [TestFixture]
+ public class StringResourceTests
+ {
+ [Test]
+ public void EnsureDefaults()
+ {
+ Encoding enc = Encoding.Default;
+ string FOO_CONTENT = "foo";
+ string FOO_DESCRIPTION = "foo description";
+
+ StringResource r = new StringResource(FOO_CONTENT);
+ Assert.AreEqual(FOO_CONTENT, r.Content);
+ Assert.AreEqual(enc, r.Encoding);
+ Assert.AreEqual(string.Empty, r.Description);
+
+ enc = new UTF7Encoding();
+ r = new StringResource(FOO_CONTENT, enc, FOO_DESCRIPTION);
+ Assert.AreEqual(FOO_CONTENT, r.Content);
+ Assert.AreEqual(enc, r.Encoding);
+ Assert.AreEqual(FOO_DESCRIPTION, r.Description);
+ }
+
+ [Test]
+ public void ReturnsCorrectEncodedStream()
+ {
+ string FOO_CONTENT = "foo\u4567";
+ StringResource r = new StringResource(FOO_CONTENT, Encoding.GetEncoding("utf-16"));
+ Assert.AreEqual(FOO_CONTENT, r.Content);
+ Stream istm = r.InputStream;
+ Assert.IsTrue(istm.CanRead);
+
+ byte[] chars = new byte[istm.Length];
+ istm.Read(chars, 0, chars.Length);
+ istm.Close();
+ string result = Encoding.GetEncoding("utf-16").GetString( chars );
+ Assert.AreEqual(FOO_CONTENT, result);
+ }
+
+ [Test]
+ [ExpectedException(typeof(NotSupportedException))]
+ public void DoesntSupportRelativeResources()
+ {
+ StringResource r = new StringResource(string.Empty);
+ r.CreateRelative("foo");
+ }
+
+ [Test]
+ public void AcceptsNullContent()
+ {
+ Encoding utf7 = new UTF7Encoding();
+ StringResource r = new StringResource(null, utf7);
+ Assert.AreEqual(string.Empty, r.Content);
+ Stream stm = r.InputStream;
+ Assert.IsTrue(stm.CanRead);
+ Assert.IsNotNull(stm);
+ Assert.AreEqual(0, stm.Length);
+ stm.Close();
+ }
+
+ [Test]
+ public void AlwaysExists()
+ {
+ StringResource r = new StringResource(null);
+ Assert.IsTrue(r.Exists);
+ r = new StringResource(string.Empty);
+ Assert.IsTrue(r.Exists);
+ r = new StringResource("foo");
+ Assert.IsTrue(r.Exists);
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs
index 40fb7b93..263fa43c 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs
@@ -21,7 +21,7 @@
#region Imports
using NUnit.Framework;
-
+using Spring.Core.IO;
using Spring.Objects.Factory.Support;
#endregion
diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2003.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2003.csproj
index 532ab9f5..2db53490 100644
--- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2003.csproj
+++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2003.csproj
@@ -188,11 +188,6 @@
SubType = "Code"
BuildAction = "Compile"
/>
-
+
+
@@ -646,7 +647,6 @@
Code
-