using System.IO; using System.Xml; using IBatisNet.Common.Utilities; using NUnit.Framework; namespace IBatisNet.Common.Test.NUnit.CommonTests.Utilities { /// /// Description résumée de ResourcesTest. /// [TestFixture] public class ResourcesTest { #region SetUp & TearDown /// /// SetUp /// [SetUp] public void SetUp() { } /// /// TearDown /// [TearDown] public void Dispose() { } #endregion #region Test ResourcesTest /// /// Test loading Embedded Resource /// [Test] public void TestEmbeddedResource() { XmlDocument doc = null; doc = Resources.GetEmbeddedResourceAsXmlDocument("IBatisNet.Common.Test.properties.xml, IBatisNet.Common.Test"); Assert.IsNotNull(doc); Assert.IsTrue(doc.HasChildNodes); Assert.AreEqual(doc.ChildNodes.Count,2); Assert.AreEqual(doc.SelectNodes("/settings/add").Count, 4); } /// /// Test loading Embedded Resource /// [Test] public void TestEmbeddedResourceWhenNamespaceDiffersFromAssemblyName() { XmlDocument doc = null; doc = Resources.GetEmbeddedResourceAsXmlDocument("CompanyName.ProductName.Maps.ISCard.xml, OctopusService"); Assert.IsNotNull(doc); Assert.IsTrue(doc.HasChildNodes); Assert.AreEqual(doc.ChildNodes.Count,2); } #endregion #region GetFileInfo Tests [Test] public void GetFileInfoWithRelative() { FileInfo fileInfo = Resources.GetFileInfo("IBatisNet.Common.Test.dll"); Assert.IsNotNull(fileInfo); } [Test] public void GetFileInfoWithAbsolute() { string resourcePath = Resources.ApplicationBase+Path.DirectorySeparatorChar+"IBatisNet.Common.Test.dll"; FileInfo fileInfo = Resources.GetFileInfo(resourcePath); Assert.IsNotNull(fileInfo); } [Test] public void GetFileInfoWithAbsoluteProtocol() { string resourcePath = "file://"+Resources.ApplicationBase+Path.DirectorySeparatorChar+"IBatisNet.Common.Test.dll"; FileInfo fileInfo = Resources.GetFileInfo(resourcePath); Assert.IsNotNull(fileInfo); } [Test] public void GetFileInfoWithAbsoluteProtocolPlusSlash() { string resourcePath = "file:///"+Resources.ApplicationBase+Path.DirectorySeparatorChar+"IBatisNet.Common.Test.dll"; FileInfo fileInfo = Resources.GetFileInfo(resourcePath); Assert.IsNotNull(fileInfo); } #endregion #region GetConfigAsXmlDocument Tests [Test] public void GetConfigAsXmlDocumentWithAbsolute() { string resourcePath = Resources.ApplicationBase+Path.DirectorySeparatorChar+"SqlMap_MSSQL_SqlClient.config"; XmlDocument doc = Resources.GetConfigAsXmlDocument(resourcePath); Assert.IsNotNull(doc); } [Test] public void GetConfigAsXmlDocumentWithAbsoluteProtocol() { string resourcePath = "file://"+Resources.ApplicationBase+Path.DirectorySeparatorChar+"SqlMap_MSSQL_SqlClient.config"; XmlDocument doc = Resources.GetConfigAsXmlDocument(resourcePath); Assert.IsNotNull(doc); } [Test] public void GetConfigAsXmlDocumentWithAbsoluteProtocolPlusSlash() { XmlDocument doc = Resources.GetConfigAsXmlDocument("file:///"+Resources.ApplicationBase+Path.DirectorySeparatorChar+"SqlMap_MSSQL_SqlClient.config"); Assert.IsNotNull(doc); } [Test] public void GetConfigAsXmlDocumentWithRelative() { XmlDocument doc = Resources.GetConfigAsXmlDocument("SqlMap_MSSQL_SqlClient.config"); Assert.IsNotNull(doc); } #endregion } }