Fixed why all the unit tests were failing. Ported over a couple of unit tests from the legacy test project to see how
easy it would be and it looks pretty easy, just need the propery initialization data for the tests. Currently ported over the Dictionary biz logic tests.... most fail but pretty sure it's due to init data.
This commit is contained in:
540
src/Umbraco.Tests/BusinessLogic/DictionaryTest.cs
Normal file
540
src/Umbraco.Tests/BusinessLogic/DictionaryTest.cs
Normal file
@@ -0,0 +1,540 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using umbraco.cms.businesslogic;
|
||||
using System;
|
||||
using System.Xml;
|
||||
using umbraco.cms.businesslogic.language;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Umbraco.Tests.BusinessLogic
|
||||
{
|
||||
//TODO: This was ported over from the previous unit tests, need to make them work now :)
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for Dictionary_DictionaryItemTest and is intended
|
||||
///to contain all Dictionary_DictionaryItemTest Unit Tests
|
||||
///</summary>
|
||||
[TestFixture]
|
||||
public class DictionaryTest : BaseWebTest
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
CreateNew();
|
||||
}
|
||||
|
||||
[Test()]
|
||||
public void Dictionary_Get_Top_Level_Items()
|
||||
{
|
||||
var items = Dictionary.getTopMostItems;
|
||||
|
||||
var d = CreateNew();
|
||||
|
||||
Assert.AreEqual(items.Count() + 1, Dictionary.getTopMostItems.Count());
|
||||
|
||||
DeleteItem(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new dictionary entry, adds values for all languages assigned, then deletes the
|
||||
/// entry and ensure that all other data is gone too.
|
||||
///</summary>
|
||||
[Test()]
|
||||
public void Dictionary_Create_Add_Text_And_Delete()
|
||||
{
|
||||
var d = CreateNew();
|
||||
|
||||
//set the values for all languages
|
||||
var langs = Language.GetAllAsList();
|
||||
foreach (var l in langs)
|
||||
{
|
||||
var val = "TEST" + Guid.NewGuid().ToString("N");
|
||||
d.setValue(l.id, val);
|
||||
//make sure the values are there
|
||||
Assert.AreEqual(val, d.Value(l.id));
|
||||
}
|
||||
|
||||
DeleteItem(d);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for IsTopMostItem
|
||||
///</summary>
|
||||
[Test()]
|
||||
public void Dictionary_IsTopMostItem()
|
||||
{
|
||||
var parent = CreateNew();
|
||||
|
||||
//create a child
|
||||
var childId = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", parent.key);
|
||||
Assert.IsTrue(childId > 0);
|
||||
var child = new Dictionary.DictionaryItem(childId);
|
||||
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<Dictionary.DictionaryItem>(child));
|
||||
|
||||
Assert.IsTrue(parent.IsTopMostItem());
|
||||
Assert.IsFalse(child.IsTopMostItem());
|
||||
|
||||
DeleteItem(child);
|
||||
DeleteItem(parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the Parent and Children properties and ensures that the relationships work both ways
|
||||
///</summary>
|
||||
[Test()]
|
||||
public void Dictionary_Parent_Child_Relationship()
|
||||
{
|
||||
var parent = CreateNew();
|
||||
|
||||
//create a child
|
||||
var childId = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", parent.key);
|
||||
Assert.IsTrue(childId > 0);
|
||||
var child = new Dictionary.DictionaryItem(childId);
|
||||
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<Dictionary.DictionaryItem>(child));
|
||||
|
||||
//set the parent relationship
|
||||
Assert.AreEqual(parent.id, child.Parent.id);
|
||||
Assert.AreEqual(parent.key, child.Parent.key);
|
||||
Assert.AreEqual(parent.UniqueId, child.Parent.UniqueId);
|
||||
|
||||
//test the child relationship
|
||||
Assert.IsTrue(parent.hasChildren);
|
||||
Assert.AreEqual(1, parent.Children.Length);
|
||||
Assert.AreEqual(child.id, parent.Children.First().id);
|
||||
Assert.AreEqual(child.key, parent.Children.First().key);
|
||||
Assert.AreEqual(child.UniqueId, parent.Children.First().UniqueId);
|
||||
|
||||
DeleteItem(child);
|
||||
DeleteItem(parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a parent with existing children and ensures they are all gone.
|
||||
/// </summary>
|
||||
[Test()]
|
||||
public void Dictionary_Delete_Parent_With_Children()
|
||||
{
|
||||
var parent = CreateNew();
|
||||
|
||||
//create a child
|
||||
var childId1 = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", parent.key);
|
||||
Assert.IsTrue(childId1 > 0);
|
||||
var child1 = new Dictionary.DictionaryItem(childId1);
|
||||
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<Dictionary.DictionaryItem>(child1));
|
||||
|
||||
//create a child
|
||||
var childId2 = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", parent.key);
|
||||
Assert.IsTrue(childId2 > 0);
|
||||
var child2 = new Dictionary.DictionaryItem(childId2);
|
||||
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<Dictionary.DictionaryItem>(child2));
|
||||
|
||||
Assert.IsTrue(parent.hasChildren);
|
||||
Assert.AreEqual(2, parent.Children.Length);
|
||||
|
||||
|
||||
DeleteItem(parent);
|
||||
|
||||
//make sure kids are gone
|
||||
var notFound = false;
|
||||
try
|
||||
{
|
||||
var check = new Dictionary.DictionaryItem(childId1);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
notFound = true;
|
||||
}
|
||||
Assert.IsTrue(notFound);
|
||||
|
||||
notFound = false;
|
||||
try
|
||||
{
|
||||
var check = new Dictionary.DictionaryItem(childId2);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
notFound = true;
|
||||
}
|
||||
Assert.IsTrue(notFound);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Guid constructor test
|
||||
///</summary>
|
||||
[Test()]
|
||||
public void Dictionary_Contructor_Guid()
|
||||
{
|
||||
var d = CreateNew();
|
||||
|
||||
var same = new Dictionary.DictionaryItem(d.UniqueId);
|
||||
|
||||
Assert.AreEqual(d.id, same.id);
|
||||
Assert.AreEqual(d.key, same.key);
|
||||
Assert.AreEqual(d.UniqueId, same.UniqueId);
|
||||
|
||||
DeleteItem(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// key constructor test
|
||||
/// </summary>
|
||||
[Test()]
|
||||
public void Dictionary_Contructor_Key()
|
||||
{
|
||||
var d = CreateNew();
|
||||
|
||||
var same = new Dictionary.DictionaryItem(d.key);
|
||||
|
||||
Assert.AreEqual(d.id, same.id);
|
||||
Assert.AreEqual(d.key, same.key);
|
||||
Assert.AreEqual(d.UniqueId, same.UniqueId);
|
||||
|
||||
DeleteItem(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ToXml
|
||||
///</summary>
|
||||
[Test()]
|
||||
public void Dictionary_ToXml()
|
||||
{
|
||||
var d = CreateNew();
|
||||
|
||||
//create a child
|
||||
var childId = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "", d.key);
|
||||
Assert.IsTrue(childId > 0);
|
||||
var child = new Dictionary.DictionaryItem(childId);
|
||||
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<Dictionary.DictionaryItem>(child));
|
||||
|
||||
var xml = new XmlDocument();
|
||||
|
||||
var output = d.ToXml(xml);
|
||||
|
||||
Assert.AreEqual("DictionaryItem", output.Name);
|
||||
Assert.IsTrue(output.HasChildNodes);
|
||||
Assert.IsNotNull(output.Attributes["Key"].Value);
|
||||
Assert.AreEqual(1, output.ChildNodes.OfType<XmlElement>().Where(x => x.Name == "DictionaryItem").Count());
|
||||
|
||||
DeleteItem(child);
|
||||
DeleteItem(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test to change the key of an element
|
||||
///</summary>
|
||||
[Test()]
|
||||
public void Dictionary_Change_Key()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
|
||||
var d = CreateNew();
|
||||
|
||||
var oldKey = d.key;
|
||||
var newKey = "NEWKEY" + Guid.NewGuid().ToString("N");
|
||||
|
||||
d.key = newKey;
|
||||
Assert.AreNotEqual(oldKey, d.key);
|
||||
Assert.AreEqual(newKey, d.key);
|
||||
|
||||
//check with sql that the key is definitely changed
|
||||
var count = Application.SqlHelper.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsDictionary WHERE [key]=@key",
|
||||
Application.SqlHelper.CreateParameter("@key", newKey));
|
||||
Assert.AreEqual(1, count);
|
||||
|
||||
count = Application.SqlHelper.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsDictionary WHERE [key]=@key",
|
||||
Application.SqlHelper.CreateParameter("@key", oldKey));
|
||||
Assert.AreEqual(0, count);
|
||||
|
||||
DeleteItem(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to create a duplicate key and ensures it's not possible.
|
||||
/// </summary>
|
||||
[Test()]
|
||||
public void Dictionary_Attempt_Duplicate_Key()
|
||||
{
|
||||
var key = "Test" + Guid.NewGuid().ToString("N");
|
||||
var d1Id = Dictionary.DictionaryItem.addKey(key, "");
|
||||
Assert.IsTrue(d1Id > 0);
|
||||
var d1 = new Dictionary.DictionaryItem(d1Id);
|
||||
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<Dictionary.DictionaryItem>(d1));
|
||||
|
||||
var alreadyExists = false;
|
||||
try
|
||||
{
|
||||
var d2Id = Dictionary.DictionaryItem.addKey(key, "");
|
||||
Assert.IsTrue(d2Id > 0);
|
||||
var d2 = new Dictionary.DictionaryItem(d2Id);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
alreadyExists = true;
|
||||
}
|
||||
Assert.IsTrue(alreadyExists);
|
||||
|
||||
DeleteItem(d1);
|
||||
}
|
||||
|
||||
#region Private methods
|
||||
|
||||
private Dictionary.DictionaryItem CreateNew()
|
||||
{
|
||||
var id = Dictionary.DictionaryItem.addKey("Test" + Guid.NewGuid().ToString("N"), "");
|
||||
Assert.IsTrue(id > 0);
|
||||
|
||||
var d = new Dictionary.DictionaryItem(id);
|
||||
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<Dictionary.DictionaryItem>(d));
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
private void DeleteItem(Dictionary.DictionaryItem d)
|
||||
{
|
||||
var id = d.id;
|
||||
|
||||
d.delete();
|
||||
|
||||
var notFound = false;
|
||||
try
|
||||
{
|
||||
var check = new Dictionary.DictionaryItem(id);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
notFound = true;
|
||||
}
|
||||
Assert.IsTrue(notFound, "The item with key " + d.key + " still exists!");
|
||||
|
||||
//check with sql that the language text is gone
|
||||
var count = Application.SqlHelper.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsLanguageText WHERE uniqueId=@uniqueId",
|
||||
Application.SqlHelper.CreateParameter("@uniqueId", d.UniqueId));
|
||||
Assert.AreEqual(0, count);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Tests to write
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////A test for Import
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void ImportTest()
|
||||
//{
|
||||
// XmlNode xmlData = null; // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem parent = null; // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem expected = null; // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem actual;
|
||||
// actual = Dictionary.DictionaryItem.Import(xmlData, parent);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Import
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void ImportTest1()
|
||||
//{
|
||||
// XmlNode xmlData = null; // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem expected = null; // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem actual;
|
||||
// actual = Dictionary.DictionaryItem.Import(xmlData);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////A test for Save
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void SaveTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// target.Save();
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////A test for Value
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void ValueTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// int languageId = 0; // TODO: Initialize to an appropriate value
|
||||
// string expected = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string actual;
|
||||
// actual = target.Value(languageId);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Value
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void ValueTest1()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// string expected = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string actual;
|
||||
// actual = target.Value();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for addKey
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void addKeyTest()
|
||||
//{
|
||||
// string key = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string defaultValue = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// int expected = 0; // TODO: Initialize to an appropriate value
|
||||
// int actual;
|
||||
// actual = Dictionary.DictionaryItem.addKey(key, defaultValue);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for addKey
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void addKeyTest1()
|
||||
//{
|
||||
// string key = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string defaultValue = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string parentKey = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// int expected = 0; // TODO: Initialize to an appropriate value
|
||||
// int actual;
|
||||
// actual = Dictionary.DictionaryItem.addKey(key, defaultValue, parentKey);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for delete
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void deleteTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// target.delete();
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for hasKey
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void hasKeyTest()
|
||||
//{
|
||||
// string key = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// bool expected = false; // TODO: Initialize to an appropriate value
|
||||
// bool actual;
|
||||
// actual = Dictionary.DictionaryItem.hasKey(key);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for setValue
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void setValueTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// int languageId = 0; // TODO: Initialize to an appropriate value
|
||||
// string value = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// target.setValue(languageId, value);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for setValue
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void setValueTest1()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// string value = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// target.setValue(value);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Children
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void ChildrenTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem[] actual;
|
||||
// actual = target.Children;
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Parent
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void ParentTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem actual;
|
||||
// actual = target.Parent;
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for hasChildren
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void hasChildrenTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// bool actual;
|
||||
// actual = target.hasChildren;
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for id
|
||||
/////</summary>
|
||||
//[Test()]
|
||||
//public void idTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Dictionary.DictionaryItem target = new Dictionary.DictionaryItem(id); // TODO: Initialize to an appropriate value
|
||||
// int actual;
|
||||
// actual = target.id;
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,9 @@ using Umbraco.Core;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Routing;
|
||||
using umbraco;
|
||||
using umbraco.BusinessLogic;
|
||||
|
||||
namespace Umbraco.Tests
|
||||
namespace Umbraco.Tests.ContentStores
|
||||
{
|
||||
[TestFixture]
|
||||
public class PublishContentStoreTests
|
||||
|
||||
43
src/Umbraco.Tests/IO/IOHelperTest.cs
Normal file
43
src/Umbraco.Tests/IO/IOHelperTest.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Tests.IO
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for IOHelperTest and is intended
|
||||
///to contain all IOHelperTest Unit Tests
|
||||
///</summary>
|
||||
[TestFixture()]
|
||||
public class IOHelperTest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///A test for MapPath verifying that HttpContext method (which includes vdirs) matches non-HttpContext method
|
||||
///</summary>
|
||||
[Test]
|
||||
public void IOHelper_MapPathTestVDirTraversal()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Bin, true), IOHelper.MapPath(SystemDirectories.Bin, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Config, true), IOHelper.MapPath(SystemDirectories.Config, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Css, true), IOHelper.MapPath(SystemDirectories.Css, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Data, true), IOHelper.MapPath(SystemDirectories.Data, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Install, true), IOHelper.MapPath(SystemDirectories.Install, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Masterpages, true), IOHelper.MapPath(SystemDirectories.Masterpages, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Media, true), IOHelper.MapPath(SystemDirectories.Media, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Packages, true), IOHelper.MapPath(SystemDirectories.Packages, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Preview, true), IOHelper.MapPath(SystemDirectories.Preview, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.MacroScripts, true), IOHelper.MapPath(SystemDirectories.MacroScripts, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Root, true), IOHelper.MapPath(SystemDirectories.Root, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Scripts, true), IOHelper.MapPath(SystemDirectories.Scripts, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Umbraco, true), IOHelper.MapPath(SystemDirectories.Umbraco, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.UmbracoClient, true), IOHelper.MapPath(SystemDirectories.UmbracoClient, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.UserControls, true), IOHelper.MapPath(SystemDirectories.UserControls, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.WebServices, true), IOHelper.MapPath(SystemDirectories.WebServices, false));
|
||||
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Xslt, true), IOHelper.MapPath(SystemDirectories.Xslt, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web.Routing;
|
||||
using System.Xml;
|
||||
@@ -14,7 +15,7 @@ using umbraco.cms.businesslogic.template;
|
||||
|
||||
namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
[TestFixture]
|
||||
[TestFixture, RequiresSTA]
|
||||
public abstract class BaseWebTest
|
||||
{
|
||||
|
||||
@@ -22,6 +23,9 @@ namespace Umbraco.Tests.TestHelpers
|
||||
public virtual void Initialize()
|
||||
{
|
||||
TestHelper.SetupLog4NetForTests();
|
||||
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", TestHelper.CurrentAssemblyDirectory);
|
||||
|
||||
if (RequiresDbSetup)
|
||||
TestHelper.InitializeDatabase();
|
||||
Resolution.Freeze();
|
||||
@@ -36,6 +40,8 @@ namespace Umbraco.Tests.TestHelpers
|
||||
[TearDown]
|
||||
public virtual void TearDown()
|
||||
{
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", null);
|
||||
|
||||
//reset the app context
|
||||
ApplicationContext.Current = null;
|
||||
Resolution.IsFrozen = false;
|
||||
|
||||
@@ -53,10 +53,12 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BusinessLogic\DictionaryTest.cs" />
|
||||
<Compile Include="ContentStores\PublishMediaStoreTests.cs" />
|
||||
<Compile Include="DynamicDocument\PublishedContentDataTableTests.cs" />
|
||||
<Compile Include="DynamicDocument\PublishedContentTests.cs" />
|
||||
<Compile Include="HtmlHelperExtensionMethodsTests.cs" />
|
||||
<Compile Include="IO\IOHelperTest.cs" />
|
||||
<Compile Include="LibraryTests.cs" />
|
||||
<Compile Include="Resolvers\ActionsResolverTests.cs" />
|
||||
<Compile Include="AsynchronousRollingFileAppenderTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user