@@ -17,6 +17,18 @@ namespace umbraco.Test
|
||||
[TestClass()]
|
||||
public class DictionaryTest
|
||||
{
|
||||
[TestMethod()]
|
||||
public void Dictionary_Get_Top_Level_Items()
|
||||
{
|
||||
var items = Dictionary.getTopMostItems;
|
||||
|
||||
var d = CreateNew();
|
||||
|
||||
Assert.AreEqual<int>(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.
|
||||
@@ -232,6 +244,34 @@ namespace umbraco.Test
|
||||
DeleteItem(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to create a duplicate key and ensures it's not possible.
|
||||
/// </summary>
|
||||
[TestMethod()]
|
||||
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.IsInstanceOfType(d1, typeof(Dictionary.DictionaryItem));
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -168,11 +168,11 @@ namespace umbraco.Test
|
||||
|
||||
target.Copy(parentId, m_User, RelateToOrignal);
|
||||
|
||||
Assert.AreEqual(childrenIds.Count() + 1, GetChildNodesOfParent(target).Count());
|
||||
|
||||
Document parent = new Document(parentId);
|
||||
var parentChildNodes = GetChildNodesOfParent(target);
|
||||
Assert.AreEqual(childrenIds.Count() + 1, parentChildNodes.Count());
|
||||
|
||||
//get the children difference which should be the new node
|
||||
var diff = parent.Children.ToList().Select(x => x.Id).Except(childrenIds);
|
||||
var diff = parentChildNodes.Select(x => x.Id).Except(childrenIds);
|
||||
|
||||
Assert.AreEqual(1, diff.Count());
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace umbraco.Test
|
||||
///A test for GetAll
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void MediaType_GetAllTest()
|
||||
public void MediaType_Get_All()
|
||||
{
|
||||
//check with sql that it's the correct number of children
|
||||
var ids = new List<int>();
|
||||
@@ -51,7 +51,7 @@ namespace umbraco.Test
|
||||
/// moved to the recycle bin.
|
||||
/// </summary>
|
||||
[TestMethod()]
|
||||
public void MediaType_DeleteDocTypeWithContentAndChildrenOfDifferentDocTypes()
|
||||
public void MediaType_Delete_Media_Type_With_Media_And_Children_Of_Diff_Media_Types()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace umbraco.Test
|
||||
/// Tests adding every type of property to a new media type on a new tab, then delete the tab, then the media type
|
||||
/// </summary>
|
||||
[TestMethod()]
|
||||
public void MediaType_AddPropertiesToTabThenDeleteItTest()
|
||||
public void MediaType_Add_Properties_To_Tab_Then_Delete_It_Test()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
|
||||
|
||||
627
umbraco.Test/MemberTest.cs
Normal file
627
umbraco.Test/MemberTest.cs
Normal file
@@ -0,0 +1,627 @@
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Xml;
|
||||
using System.Linq;
|
||||
|
||||
namespace umbraco.Test
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for MemberTest and is intended
|
||||
///to contain all MemberTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class MemberTest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new member type and member, then deletes it
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void Member_Make_New()
|
||||
{
|
||||
|
||||
var mt = MemberType.MakeNew(m_User, "TEST" + Guid.NewGuid().ToString("N"));
|
||||
var m = Member.MakeNew("TEST" + Guid.NewGuid().ToString("N"),
|
||||
"TEST" + Guid.NewGuid().ToString("N") + "@test.com", mt, m_User);
|
||||
|
||||
Assert.IsInstanceOfType(m, typeof(Member));
|
||||
Assert.IsTrue(m.Id > 0);
|
||||
|
||||
m.delete();
|
||||
Assert.IsFalse(Member.IsNode(m.Id));
|
||||
|
||||
mt.delete();
|
||||
Assert.IsFalse(MemberType.IsNode(mt.Id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///Creates a new member type, member group and a member, then adds the member to the group.
|
||||
///then deletes the data in order for cleanup
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void Member_Add_To_Group()
|
||||
{
|
||||
var mt = MemberType.MakeNew(m_User, "TEST" + Guid.NewGuid().ToString("N"));
|
||||
var m = Member.MakeNew("TEST" + Guid.NewGuid().ToString("N"),
|
||||
"TEST" + Guid.NewGuid().ToString("N") + "@test.com", mt, m_User);
|
||||
|
||||
var mg = MemberGroup.MakeNew("TEST" + Guid.NewGuid().ToString("N"), m_User);
|
||||
Assert.IsInstanceOfType(mg, typeof(MemberGroup));
|
||||
Assert.IsTrue(mg.Id > 0);
|
||||
|
||||
//add the member to the group
|
||||
m.AddGroup(mg.Id);
|
||||
|
||||
//ensure they are added
|
||||
Assert.AreEqual(1, m.Groups.Count);
|
||||
Assert.AreEqual<int>(mg.Id, ((MemberGroup)m.Groups.Cast<DictionaryEntry>().First().Value).Id);
|
||||
|
||||
//remove the grup
|
||||
m.RemoveGroup(mg.Id);
|
||||
|
||||
//ensure they are removed
|
||||
Assert.AreEqual(0, m.Groups.Count);
|
||||
|
||||
mg.delete();
|
||||
Assert.IsFalse(Member.IsNode(mg.Id));
|
||||
|
||||
m.delete();
|
||||
Assert.IsFalse(Member.IsNode(m.Id));
|
||||
|
||||
mt.delete();
|
||||
Assert.IsFalse(MemberType.IsNode(mt.Id));
|
||||
}
|
||||
|
||||
#region Private members
|
||||
private User m_User = new User(0);
|
||||
#endregion
|
||||
|
||||
#region Test to write
|
||||
///// <summary>
|
||||
/////A test for Member Constructor
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void MemberConstructorTest()
|
||||
//{
|
||||
// int id = 0; // TODO: Initialize to an appropriate value
|
||||
// bool noSetup = false; // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id, noSetup);
|
||||
// Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Member Constructor
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void MemberConstructorTest1()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// bool noSetup = false; // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id, noSetup);
|
||||
// Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Member Constructor
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void MemberConstructorTest2()
|
||||
//{
|
||||
// int id = 0; // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id);
|
||||
// Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Member Constructor
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void MemberConstructorTest3()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id);
|
||||
// Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////A test for AddMemberToCache
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void AddMemberToCacheTest()
|
||||
//{
|
||||
// Member m = null; // TODO: Initialize to an appropriate value
|
||||
// Member.AddMemberToCache(m);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for AddMemberToCache
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void AddMemberToCacheTest1()
|
||||
//{
|
||||
// Member m = null; // TODO: Initialize to an appropriate value
|
||||
// bool UseSession = false; // TODO: Initialize to an appropriate value
|
||||
// TimeSpan TimespanForCookie = new TimeSpan(); // TODO: Initialize to an appropriate value
|
||||
// Member.AddMemberToCache(m, UseSession, TimespanForCookie);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for CachedMembers
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void CachedMembersTest()
|
||||
//{
|
||||
// Hashtable expected = null; // TODO: Initialize to an appropriate value
|
||||
// Hashtable actual;
|
||||
// actual = Member.CachedMembers();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for ChangePassword
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void ChangePasswordTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// string newPassword = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// target.ChangePassword(newPassword);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for ClearMemberFromClient
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void ClearMemberFromClientTest()
|
||||
//{
|
||||
// int NodeId = 0; // TODO: Initialize to an appropriate value
|
||||
// Member.ClearMemberFromClient(NodeId);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for ClearMemberFromClient
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void ClearMemberFromClientTest1()
|
||||
//{
|
||||
// Member m = null; // TODO: Initialize to an appropriate value
|
||||
// Member.ClearMemberFromClient(m);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for CurrentMemberId
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void CurrentMemberIdTest()
|
||||
//{
|
||||
// int expected = 0; // TODO: Initialize to an appropriate value
|
||||
// int actual;
|
||||
// actual = Member.CurrentMemberId();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for DeleteFromType
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void DeleteFromTypeTest()
|
||||
//{
|
||||
// MemberType dt = null; // TODO: Initialize to an appropriate value
|
||||
// Member.DeleteFromType(dt);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetCurrentMember
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetCurrentMemberTest()
|
||||
//{
|
||||
// Member expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member actual;
|
||||
// actual = Member.GetCurrentMember();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetMemberByName
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetMemberByNameTest()
|
||||
//{
|
||||
// string usernameToMatch = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// bool matchByNameInsteadOfLogin = false; // TODO: Initialize to an appropriate value
|
||||
// Member[] expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member[] actual;
|
||||
// actual = Member.GetMemberByName(usernameToMatch, matchByNameInsteadOfLogin);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetMemberFromCache
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetMemberFromCacheTest()
|
||||
//{
|
||||
// int id = 0; // TODO: Initialize to an appropriate value
|
||||
// Member expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member actual;
|
||||
// actual = Member.GetMemberFromCache(id);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetMemberFromEmail
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetMemberFromEmailTest()
|
||||
//{
|
||||
// string email = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// Member expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member actual;
|
||||
// actual = Member.GetMemberFromEmail(email);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetMemberFromLoginAndEncodedPassword
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetMemberFromLoginAndEncodedPasswordTest()
|
||||
//{
|
||||
// string loginName = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string password = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// Member expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member actual;
|
||||
// actual = Member.GetMemberFromLoginAndEncodedPassword(loginName, password);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetMemberFromLoginName
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetMemberFromLoginNameTest()
|
||||
//{
|
||||
// string loginName = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// Member expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member actual;
|
||||
// actual = Member.GetMemberFromLoginName(loginName);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetMemberFromLoginNameAndPassword
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetMemberFromLoginNameAndPasswordTest()
|
||||
//{
|
||||
// string loginName = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string password = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// Member expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member actual;
|
||||
// actual = Member.GetMemberFromLoginNameAndPassword(loginName, password);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for InUmbracoMemberMode
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void InUmbracoMemberModeTest()
|
||||
//{
|
||||
// bool expected = false; // TODO: Initialize to an appropriate value
|
||||
// bool actual;
|
||||
// actual = Member.InUmbracoMemberMode();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for IsLoggedOn
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void IsLoggedOnTest()
|
||||
//{
|
||||
// bool expected = false; // TODO: Initialize to an appropriate value
|
||||
// bool actual;
|
||||
// actual = Member.IsLoggedOn();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for IsMember
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void IsMemberTest()
|
||||
//{
|
||||
// string loginName = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// bool expected = false; // TODO: Initialize to an appropriate value
|
||||
// bool actual;
|
||||
// actual = Member.IsMember(loginName);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for IsUsingUmbracoRoles
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void IsUsingUmbracoRolesTest()
|
||||
//{
|
||||
// bool expected = false; // TODO: Initialize to an appropriate value
|
||||
// bool actual;
|
||||
// actual = Member.IsUsingUmbracoRoles();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////A test for MakeNew
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void MakeNewTest1()
|
||||
//{
|
||||
// string Name = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// MemberType mbt = null; // TODO: Initialize to an appropriate value
|
||||
// User u = null; // TODO: Initialize to an appropriate value
|
||||
// Member expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member actual;
|
||||
// actual = Member.MakeNew(Name, mbt, u);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for RemoveGroup
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void RemoveGroupTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// int GroupId = 0; // TODO: Initialize to an appropriate value
|
||||
// target.RemoveGroup(GroupId);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for RemoveMemberFromCache
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void RemoveMemberFromCacheTest()
|
||||
//{
|
||||
// Member m = null; // TODO: Initialize to an appropriate value
|
||||
// Member.RemoveMemberFromCache(m);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for RemoveMemberFromCache
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void RemoveMemberFromCacheTest1()
|
||||
//{
|
||||
// int NodeId = 0; // TODO: Initialize to an appropriate value
|
||||
// Member.RemoveMemberFromCache(NodeId);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Save
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void SaveTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(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 ToXml
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void ToXmlTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// XmlDocument xd = null; // TODO: Initialize to an appropriate value
|
||||
// bool Deep = false; // TODO: Initialize to an appropriate value
|
||||
// XmlNode expected = null; // TODO: Initialize to an appropriate value
|
||||
// XmlNode actual;
|
||||
// actual = target.ToXml(xd, Deep);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for XmlGenerate
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void XmlGenerateTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// XmlDocument xd = null; // TODO: Initialize to an appropriate value
|
||||
// target.XmlGenerate(xd);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////A test for getAllOtherMembers
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void getAllOtherMembersTest()
|
||||
//{
|
||||
// Member[] expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member[] actual;
|
||||
// actual = Member.getAllOtherMembers();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for getMemberFromFirstLetter
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void getMemberFromFirstLetterTest()
|
||||
//{
|
||||
// char letter = '\0'; // TODO: Initialize to an appropriate value
|
||||
// Member[] expected = null; // TODO: Initialize to an appropriate value
|
||||
// Member[] actual;
|
||||
// actual = Member.getMemberFromFirstLetter(letter);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Email
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void EmailTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// string expected = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string actual;
|
||||
// target.Email = expected;
|
||||
// actual = target.Email;
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetAll
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetAllTest()
|
||||
//{
|
||||
// Member[] actual;
|
||||
// actual = Member.GetAll;
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Groups
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GroupsTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// Hashtable actual;
|
||||
// actual = target.Groups;
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for LoginName
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void LoginNameTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// string expected = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string actual;
|
||||
// target.LoginName = expected;
|
||||
// actual = target.LoginName;
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Password
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void PasswordTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// string expected = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string actual;
|
||||
// target.Password = expected;
|
||||
// actual = target.Password;
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Text
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void TextTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Member target = new Member(id); // TODO: Initialize to an appropriate value
|
||||
// string expected = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// string actual;
|
||||
// target.Text = expected;
|
||||
// actual = target.Text;
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Initialize and cleanup
|
||||
//
|
||||
//You can use the following additional attributes as you write your tests:
|
||||
//
|
||||
//Use ClassInitialize to run code before running the first test in the class
|
||||
//[ClassInitialize()]
|
||||
//public static void MyClassInitialize(TestContext testContext)
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//Use ClassCleanup to run code after all tests in a class have run
|
||||
//[ClassCleanup()]
|
||||
//public static void MyClassCleanup()
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//Use TestInitialize to run code before running each test
|
||||
//[TestInitialize()]
|
||||
//public void MyTestInitialize()
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//Use TestCleanup to run code after each test has run
|
||||
//[TestCleanup()]
|
||||
//public void MyTestCleanup()
|
||||
//{
|
||||
//}
|
||||
//
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
228
umbraco.Test/MemberTypeTest.cs
Normal file
228
umbraco.Test/MemberTypeTest.cs
Normal file
@@ -0,0 +1,228 @@
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.cms.businesslogic.propertytype;
|
||||
using System.Xml;
|
||||
|
||||
namespace umbraco.Test
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for MemberTypeTest and is intended
|
||||
///to contain all MemberTypeTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class MemberTypeTest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///A test for MakeNew
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void MemberType_Make_New()
|
||||
{
|
||||
var m = MemberType.MakeNew(m_User, "TEST" + Guid.NewGuid().ToString("N"));
|
||||
|
||||
Assert.IsInstanceOfType(m, typeof(MemberType));
|
||||
Assert.IsTrue(m.Id > 0);
|
||||
|
||||
//remove it
|
||||
m.delete();
|
||||
Assert.IsFalse(MemberType.IsNode(m.Id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a member type, create some members of the member type and then delete the member type.
|
||||
/// This should also delete all of the members.
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void MemberType_Delete_With_Assigned_Members()
|
||||
{
|
||||
|
||||
var mt1 = MemberType.MakeNew(m_User, "TEST" + Guid.NewGuid().ToString("N"));
|
||||
|
||||
//create the members
|
||||
var node1 = Member.MakeNew("TEST" + Guid.NewGuid().ToString("N"), mt1, m_User);
|
||||
var node2 = Member.MakeNew("TEST" + Guid.NewGuid().ToString("N"), mt1, m_User);
|
||||
|
||||
//do the deletion of doc type #1
|
||||
mt1.delete();
|
||||
Assert.IsFalse(MemberType.IsNode(mt1.Id));
|
||||
|
||||
//do our checks
|
||||
Assert.IsFalse(Member.IsNode(node1.Id), "node1 is not deleted");
|
||||
Assert.IsFalse(Member.IsNode(node2.Id), "node2 is not deleted");
|
||||
}
|
||||
|
||||
#region Tests to write
|
||||
///// <summary>
|
||||
/////A test for MemberType Constructor
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void MemberTypeConstructorTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// MemberType target = new MemberType(id);
|
||||
// Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for MemberType Constructor
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void MemberTypeConstructorTest1()
|
||||
//{
|
||||
// int id = 0; // TODO: Initialize to an appropriate value
|
||||
// MemberType target = new MemberType(id);
|
||||
// Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetByAlias
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetByAliasTest()
|
||||
//{
|
||||
// string Alias = string.Empty; // TODO: Initialize to an appropriate value
|
||||
// MemberType expected = null; // TODO: Initialize to an appropriate value
|
||||
// MemberType actual;
|
||||
// actual = MemberType.GetByAlias(Alias);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for MemberCanEdit
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void MemberCanEditTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// MemberType target = new MemberType(id); // TODO: Initialize to an appropriate value
|
||||
// PropertyType pt = null; // TODO: Initialize to an appropriate value
|
||||
// bool expected = false; // TODO: Initialize to an appropriate value
|
||||
// bool actual;
|
||||
// actual = target.MemberCanEdit(pt);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Save
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void SaveTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// MemberType target = new MemberType(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 ViewOnProfile
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void ViewOnProfileTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// MemberType target = new MemberType(id); // TODO: Initialize to an appropriate value
|
||||
// PropertyType pt = null; // TODO: Initialize to an appropriate value
|
||||
// bool expected = false; // TODO: Initialize to an appropriate value
|
||||
// bool actual;
|
||||
// actual = target.ViewOnProfile(pt);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for delete
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void deleteTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// MemberType target = new MemberType(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 setMemberCanEdit
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void setMemberCanEditTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// MemberType target = new MemberType(id); // TODO: Initialize to an appropriate value
|
||||
// PropertyType pt = null; // TODO: Initialize to an appropriate value
|
||||
// bool value = false; // TODO: Initialize to an appropriate value
|
||||
// target.setMemberCanEdit(pt, value);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for setMemberViewOnProfile
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void setMemberViewOnProfileTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// MemberType target = new MemberType(id); // TODO: Initialize to an appropriate value
|
||||
// PropertyType pt = null; // TODO: Initialize to an appropriate value
|
||||
// bool value = false; // TODO: Initialize to an appropriate value
|
||||
// target.setMemberViewOnProfile(pt, value);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetAll
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetAllTest()
|
||||
//{
|
||||
// MemberType[] actual;
|
||||
// actual = MemberType.GetAll;
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
private User m_User = new User(0);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialize and cleanup
|
||||
//
|
||||
//You can use the following additional attributes as you write your tests:
|
||||
//
|
||||
//Use ClassInitialize to run code before running the first test in the class
|
||||
//[ClassInitialize()]
|
||||
//public static void MyClassInitialize(TestContext testContext)
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//Use ClassCleanup to run code after all tests in a class have run
|
||||
//[ClassCleanup()]
|
||||
//public static void MyClassCleanup()
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//Use TestInitialize to run code before running each test
|
||||
//[TestInitialize()]
|
||||
//public void MyTestInitialize()
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//Use TestCleanup to run code after each test has run
|
||||
//[TestCleanup()]
|
||||
//public void MyTestCleanup()
|
||||
//{
|
||||
//}
|
||||
//
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -136,12 +136,14 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Dictionary_DictionaryItemTest.cs" />
|
||||
<Compile Include="DictionaryTest.cs" />
|
||||
<Compile Include="DocumentTest.cs" />
|
||||
<Compile Include="DocumentTypeTest.cs" />
|
||||
<Compile Include="LanguageTest.cs" />
|
||||
<Compile Include="MediaTest.cs" />
|
||||
<Compile Include="MediaTypeTest.cs" />
|
||||
<Compile Include="MemberTest.cs" />
|
||||
<Compile Include="MemberTypeTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UserTest.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -295,6 +295,11 @@ namespace umbraco.cms.businesslogic
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Empty constructor that is not suported
|
||||
/// ...why is it here?
|
||||
/// </summary>
|
||||
public CMSNode()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
@@ -310,7 +315,6 @@ namespace umbraco.cms.businesslogic
|
||||
setupNode();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CMSNode"/> class.
|
||||
/// </summary>
|
||||
@@ -320,10 +324,8 @@ namespace umbraco.cms.businesslogic
|
||||
{
|
||||
_id = id;
|
||||
|
||||
//TODO: add the following as noSetup currenlty doesn't actuall do anything!?? This can't happen until
|
||||
//inheriting classes can override setupNode instead of using their own implementation (i.e. Document: setupDocument)
|
||||
//if (!noSetup)
|
||||
//setupNode();
|
||||
if (!noSetup)
|
||||
setupNode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -336,11 +338,20 @@ namespace umbraco.cms.businesslogic
|
||||
setupNode();
|
||||
}
|
||||
|
||||
public CMSNode(IRecordsReader reader)
|
||||
public CMSNode(Guid uniqueID, bool noSetup)
|
||||
{
|
||||
_id = SqlHelper.ExecuteScalar<int>("SELECT id FROM umbracoNode WHERE uniqueID = @uniqueId", SqlHelper.CreateParameter("@uniqueId", uniqueID));
|
||||
|
||||
if (!noSetup)
|
||||
setupNode();
|
||||
}
|
||||
|
||||
protected internal CMSNode(IRecordsReader reader)
|
||||
{
|
||||
_id = reader.GetInt("id");
|
||||
PopulateCMSNodeFromReader(reader);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -41,25 +41,16 @@ namespace umbraco.cms.businesslogic
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
#region Constructors
|
||||
|
||||
public Content(int id) : base(id) { }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="noSetup"></param>
|
||||
protected Content(int id, bool noSetup) : base(id, noSetup) { }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
|
||||
protected Content(Guid id) : base(id) { }
|
||||
|
||||
protected Content(Guid id, bool noSetup) : base(id, noSetup) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Methods
|
||||
@@ -505,6 +496,8 @@ namespace umbraco.cms.businesslogic
|
||||
createNewVersion();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method for creating a new version of the data associated to the Content.
|
||||
///
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace umbraco.cms.businesslogic
|
||||
|
||||
public ContentType(int id, bool noSetup) : base(id, noSetup) { }
|
||||
|
||||
public ContentType(Guid id, bool noSetup) : base(id, noSetup) { }
|
||||
|
||||
///// <summary>
|
||||
///// Initializes a new instance of the <see cref="ContentType"/> class.
|
||||
///// </summary>
|
||||
|
||||
27
umbraco/cms/businesslogic/cache/Cache.cs
vendored
27
umbraco/cms/businesslogic/cache/Cache.cs
vendored
@@ -1,16 +1,15 @@
|
||||
using System;
|
||||
using System.Web.Caching;
|
||||
using System.Web;
|
||||
|
||||
namespace umbraco.cms.businesslogic.cache
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Cache.
|
||||
/// Used to easily store and retreive items from the cache.
|
||||
/// </summary>
|
||||
public class Cache
|
||||
{
|
||||
|
||||
public static readonly object m_Locker = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Clears everything in umbraco's runtime cache, which means that not only
|
||||
/// umbraco content is removed, but also other cache items from pages running in
|
||||
@@ -36,16 +35,9 @@ namespace umbraco.cms.businesslogic.cache
|
||||
public static void ClearCacheItem(string Key)
|
||||
{
|
||||
if (System.Web.HttpRuntime.Cache[Key] != null)
|
||||
{
|
||||
lock (m_Locker)
|
||||
{
|
||||
//check again
|
||||
if (System.Web.HttpRuntime.Cache[Key] != null)
|
||||
{
|
||||
System.Web.HttpRuntime.Cache.Remove(Key);
|
||||
System.Web.HttpContext.Current.Trace.Warn("Cache", "Item " + Key + " removed from cache");
|
||||
}
|
||||
}
|
||||
{
|
||||
HttpRuntime.Cache.Remove(Key);
|
||||
HttpContext.Current.Trace.Warn("Cache", "Item " + Key + " removed from cache");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,14 +59,7 @@ namespace umbraco.cms.businesslogic.cache
|
||||
{
|
||||
if (cacheEnumerator.Key != null && c[cacheEnumerator.Key.ToString()] != null && c[cacheEnumerator.Key.ToString()].GetType() != null && c[cacheEnumerator.Key.ToString()].GetType().ToString() == TypeName)
|
||||
{
|
||||
lock (m_Locker)
|
||||
{
|
||||
//check again
|
||||
if (cacheEnumerator.Key != null && c[cacheEnumerator.Key.ToString()] != null && c[cacheEnumerator.Key.ToString()].GetType() != null && c[cacheEnumerator.Key.ToString()].GetType().ToString() == TypeName)
|
||||
{
|
||||
c.Remove(cacheEnumerator.Key.ToString());
|
||||
}
|
||||
}
|
||||
c.Remove(cacheEnumerator.Key.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace umbraco.cms.businesslogic.media
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Contructs a media object given the Id
|
||||
/// </summary>
|
||||
@@ -49,7 +50,8 @@ namespace umbraco.cms.businesslogic.media
|
||||
|
||||
public Media(int id, bool noSetup) : base(id, noSetup) { }
|
||||
|
||||
public Media(bool optimizedMode, int id) : base(id, optimizedMode) { }
|
||||
public Media(Guid id, bool noSetup) : base(id, noSetup) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Methods
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ using System.Data;
|
||||
using System.Xml;
|
||||
using umbraco.cms.businesslogic.propertytype;
|
||||
using System.Linq;
|
||||
using umbraco.BusinessLogic;
|
||||
|
||||
namespace umbraco.cms.businesslogic.member
|
||||
{
|
||||
@@ -18,17 +19,13 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// Initializes a new instance of the MemberType class.
|
||||
/// </summary>
|
||||
/// <param name="id">MemberType id</param>
|
||||
public MemberType(int id) : base(id)
|
||||
{
|
||||
}
|
||||
public MemberType(int id) : base(id) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MemberType class.
|
||||
/// </summary>
|
||||
/// <param name="id">MemberType id</param>
|
||||
public MemberType(Guid id) : base(id)
|
||||
{
|
||||
}
|
||||
|
||||
public MemberType(Guid id) : base(id) { }
|
||||
|
||||
/// <summary>
|
||||
/// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility
|
||||
@@ -42,16 +39,14 @@ namespace umbraco.cms.businesslogic.member
|
||||
FireAfterSave(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a new MemberType
|
||||
/// </summary>
|
||||
/// <param name="Text">The name of the MemberType</param>
|
||||
/// <param name="u">Creator of the MemberType</param>
|
||||
public static MemberType MakeNew( BusinessLogic.User u,string Text)
|
||||
{
|
||||
|
||||
public static MemberType MakeNew(User u,string Text)
|
||||
{
|
||||
int ParentId= -1;
|
||||
int level = 1;
|
||||
Guid uniqueId = Guid.NewGuid();
|
||||
@@ -68,30 +63,32 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// <summary>
|
||||
/// Retrieve a list of all MemberTypes
|
||||
/// </summary>
|
||||
new public static MemberType[] GetAll {
|
||||
get
|
||||
{
|
||||
Guid[] Ids = CMSNode.getAllUniquesFromObjectType(_objectType);
|
||||
public new static MemberType[] GetAll
|
||||
{
|
||||
get
|
||||
{
|
||||
Guid[] Ids = CMSNode.getAllUniquesFromObjectType(_objectType);
|
||||
|
||||
MemberType[] retVal = new MemberType[Ids.Length];
|
||||
for (int i = 0; i < Ids.Length; i++) retVal[i] = new MemberType(Ids[i]);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
MemberType[] retVal = new MemberType[Ids.Length];
|
||||
for (int i = 0; i < Ids.Length; i++) retVal[i] = new MemberType(Ids[i]);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an true/false if the Member can edit the given data defined in the propertytype
|
||||
/// </summary>
|
||||
/// <param name="pt">Propertytype to edit</param>
|
||||
/// <returns>True if the Member can edit the data</returns>
|
||||
public bool MemberCanEdit(propertytype.PropertyType pt) {
|
||||
public bool MemberCanEdit(PropertyType pt)
|
||||
{
|
||||
if (propertyTypeRegistered(pt))
|
||||
{
|
||||
var memberCanEdit = SqlHelper.ExecuteScalar<object>("Select memberCanEdit from cmsMemberType where NodeId = " + this.Id + " And propertytypeId = " + pt.Id);
|
||||
return (Convert.ToBoolean(memberCanEdit));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a MemberType by it's alias
|
||||
@@ -110,7 +107,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// </summary>
|
||||
/// <param name="pt">Propertytype</param>
|
||||
/// <returns>True if the data should be displayed on the profilepage</returns>
|
||||
public bool ViewOnProfile(propertytype.PropertyType pt)
|
||||
public bool ViewOnProfile(PropertyType pt)
|
||||
{
|
||||
if(propertyTypeRegistered(pt))
|
||||
{
|
||||
@@ -124,19 +121,21 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// </summary>
|
||||
/// <param name="pt">PropertyType</param>
|
||||
/// <param name="value">True/False if Members of the type shoúld be able to edit the data</param>
|
||||
public void setMemberCanEdit(propertytype.PropertyType pt, bool value) {
|
||||
int tmpval = 0;
|
||||
if (value) tmpval = 1;
|
||||
if (propertyTypeRegistered(pt))
|
||||
SqlHelper.ExecuteNonQuery("Update cmsMemberType set memberCanEdit = " + tmpval + " where NodeId = " + this.Id +" And propertytypeId = "+pt.Id);
|
||||
else
|
||||
SqlHelper.ExecuteNonQuery("insert into cmsMemberType (NodeId, propertytypeid, memberCanEdit,viewOnProfile) values ("+this.Id+","+pt.Id+", "+tmpval+",0)");
|
||||
public void setMemberCanEdit(PropertyType pt, bool value)
|
||||
{
|
||||
int tmpval = 0;
|
||||
if (value) tmpval = 1;
|
||||
if (propertyTypeRegistered(pt))
|
||||
SqlHelper.ExecuteNonQuery("Update cmsMemberType set memberCanEdit = " + tmpval + " where NodeId = " + this.Id + " And propertytypeId = " + pt.Id);
|
||||
else
|
||||
SqlHelper.ExecuteNonQuery("insert into cmsMemberType (NodeId, propertytypeid, memberCanEdit,viewOnProfile) values (" + this.Id + "," + pt.Id + ", " + tmpval + ",0)");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private bool propertyTypeRegistered(propertytype.PropertyType pt) {
|
||||
return (SqlHelper.ExecuteScalar<int>("Select count(pk) as tmp from cmsMemberType where NodeId = " + this.Id +" And propertytypeId = "+pt.Id) > 0);
|
||||
}
|
||||
private bool propertyTypeRegistered(PropertyType pt)
|
||||
{
|
||||
return (SqlHelper.ExecuteScalar<int>("Select count(pk) as tmp from cmsMemberType where NodeId = " + this.Id + " And propertytypeId = " + pt.Id) > 0);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -144,7 +143,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
/// </summary>
|
||||
/// <param name="pt">PropertyType</param>
|
||||
/// <param name="value">True/False if the data should be displayed</param>
|
||||
public void setMemberViewOnProfile(propertytype.PropertyType pt, bool value)
|
||||
public void setMemberViewOnProfile(PropertyType pt, bool value)
|
||||
{
|
||||
int tmpval = 0;
|
||||
if (value) tmpval = 1;
|
||||
@@ -161,15 +160,17 @@ namespace umbraco.cms.businesslogic.member
|
||||
///
|
||||
/// Use with care
|
||||
/// </summary>
|
||||
new public void delete()
|
||||
public override void delete()
|
||||
{
|
||||
DeleteEventArgs e = new DeleteEventArgs();
|
||||
|
||||
FireBeforeDelete(e);
|
||||
|
||||
if (!e.Cancel) {
|
||||
|
||||
// delete all documents of this type
|
||||
Member.DeleteFromType(this);
|
||||
|
||||
// delete membertype specific data
|
||||
SqlHelper.ExecuteNonQuery("Delete from cmsMemberType where nodeId = " + this.Id);
|
||||
|
||||
@@ -178,55 +179,7 @@ namespace umbraco.cms.businesslogic.member
|
||||
FireAfterDelete(e);
|
||||
}
|
||||
}
|
||||
|
||||
//EVENTS
|
||||
/// <summary>
|
||||
/// The save event handler
|
||||
/// </summary>
|
||||
public delegate void SaveEventHandler(MemberType sender, SaveEventArgs e);
|
||||
/// <summary>
|
||||
/// The new event handler
|
||||
/// </summary>
|
||||
public delegate void NewEventHandler(MemberType sender, NewEventArgs e);
|
||||
/// <summary>
|
||||
/// The delete event handler
|
||||
/// </summary>
|
||||
public delegate void DeleteEventHandler(MemberType sender, DeleteEventArgs e);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a language is saved.
|
||||
/// </summary>
|
||||
public static event SaveEventHandler BeforeSave;
|
||||
protected virtual void FireBeforeSave(SaveEventArgs e) {
|
||||
if (BeforeSave != null)
|
||||
BeforeSave(this, e);
|
||||
}
|
||||
|
||||
public static event SaveEventHandler AfterSave;
|
||||
protected virtual void FireAfterSave(SaveEventArgs e) {
|
||||
if (AfterSave != null)
|
||||
AfterSave(this, e);
|
||||
}
|
||||
|
||||
public static event NewEventHandler New;
|
||||
protected virtual void OnNew(NewEventArgs e) {
|
||||
if (New != null)
|
||||
New(this, e);
|
||||
}
|
||||
|
||||
public static event DeleteEventHandler BeforeDelete;
|
||||
protected virtual void FireBeforeDelete(DeleteEventArgs e) {
|
||||
if (BeforeDelete != null)
|
||||
BeforeDelete(this, e);
|
||||
}
|
||||
|
||||
public static event DeleteEventHandler AfterDelete;
|
||||
protected virtual void FireAfterDelete(DeleteEventArgs e) {
|
||||
if (AfterDelete != null)
|
||||
AfterDelete(this, e);
|
||||
}
|
||||
|
||||
|
||||
public XmlElement ToXml(XmlDocument xd)
|
||||
{
|
||||
XmlElement root = xd.CreateElement("MemberType");
|
||||
@@ -270,5 +223,60 @@ namespace umbraco.cms.businesslogic.member
|
||||
root.AppendChild(tabs);
|
||||
return root;
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// The save event handler
|
||||
/// </summary>
|
||||
public delegate void SaveEventHandler(MemberType sender, SaveEventArgs e);
|
||||
/// <summary>
|
||||
/// The new event handler
|
||||
/// </summary>
|
||||
public delegate void NewEventHandler(MemberType sender, NewEventArgs e);
|
||||
/// <summary>
|
||||
/// The delete event handler
|
||||
/// </summary>
|
||||
public delegate void DeleteEventHandler(MemberType sender, DeleteEventArgs e);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a language is saved.
|
||||
/// </summary>
|
||||
public static event SaveEventHandler BeforeSave;
|
||||
protected virtual void FireBeforeSave(SaveEventArgs e)
|
||||
{
|
||||
if (BeforeSave != null)
|
||||
BeforeSave(this, e);
|
||||
}
|
||||
|
||||
public static event SaveEventHandler AfterSave;
|
||||
protected virtual void FireAfterSave(SaveEventArgs e)
|
||||
{
|
||||
if (AfterSave != null)
|
||||
AfterSave(this, e);
|
||||
}
|
||||
|
||||
public static event NewEventHandler New;
|
||||
protected virtual void OnNew(NewEventArgs e)
|
||||
{
|
||||
if (New != null)
|
||||
New(this, e);
|
||||
}
|
||||
|
||||
public static event DeleteEventHandler BeforeDelete;
|
||||
protected virtual void FireBeforeDelete(DeleteEventArgs e)
|
||||
{
|
||||
if (BeforeDelete != null)
|
||||
BeforeDelete(this, e);
|
||||
}
|
||||
|
||||
public static event DeleteEventHandler AfterDelete;
|
||||
protected virtual void FireAfterDelete(DeleteEventArgs e)
|
||||
{
|
||||
if (AfterDelete != null)
|
||||
AfterDelete(this, e);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,13 @@ namespace umbraco.cms.businesslogic.web
|
||||
public class Document : Content
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new document
|
||||
/// </summary>
|
||||
/// <param name="id">Id of the document</param>
|
||||
/// <param name="noSetup">true if the data shouldn't loaded from the db</param>
|
||||
public Document(Guid id, bool noSetup) : base(id) { }
|
||||
public Document(Guid id, bool noSetup) : base(id, noSetup) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Document class.
|
||||
@@ -49,8 +50,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the document</param>
|
||||
/// <param name="Version">The version of the document</param>
|
||||
public Document(int id, Guid Version)
|
||||
: base(id)
|
||||
public Document(int id, Guid Version) : base(id)
|
||||
{
|
||||
this.Version = Version;
|
||||
}
|
||||
@@ -67,9 +67,12 @@ namespace umbraco.cms.businesslogic.web
|
||||
/// <param name="id">The id of the document</param>
|
||||
public Document(Guid id) : base(id) { }
|
||||
|
||||
//TODO: SD: Implement this EVERYWHERE (90 places apparently)
|
||||
public Document(bool optimizedMode, int id)
|
||||
: base(id, optimizedMode)
|
||||
/// <summary>
|
||||
/// Initializes a Document object with one SQL query instead of many
|
||||
/// </summary>
|
||||
/// <param name="optimizedMode"></param>
|
||||
/// <param name="id"></param>
|
||||
public Document(bool optimizedMode, int id) : base(id, optimizedMode)
|
||||
{
|
||||
this._optimizedMode = optimizedMode;
|
||||
|
||||
@@ -136,6 +139,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constants and Static members
|
||||
@@ -329,9 +333,18 @@ namespace umbraco.cms.businesslogic.web
|
||||
CMSNode n = new CMSNode(ParentId);
|
||||
int newLevel = n.Level;
|
||||
newLevel++;
|
||||
MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
|
||||
|
||||
//create the cms node first
|
||||
CMSNode newNode = MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
|
||||
|
||||
//we need to create an empty document and set the underlying text property
|
||||
Document tmp = new Document(newId, true);
|
||||
tmp.SetText(Name);
|
||||
|
||||
//create the content data for the new document
|
||||
tmp.CreateContent(dct);
|
||||
|
||||
//now create the document data
|
||||
SqlHelper.ExecuteNonQuery("insert into cmsDocument (newest, nodeId, published, documentUser, versionId, Text) values (1, " +
|
||||
tmp.Id + ", 0, " +
|
||||
u.Id + ", @versionId, @text)",
|
||||
@@ -341,10 +354,10 @@ namespace umbraco.cms.businesslogic.web
|
||||
// Update the sortOrder if the parent was the root!
|
||||
if (ParentId == -1)
|
||||
{
|
||||
CMSNode c = new CMSNode(newId);
|
||||
c.sortOrder = GetRootDocuments().Length + 1;
|
||||
newNode.sortOrder = GetRootDocuments().Length + 1;
|
||||
}
|
||||
|
||||
//read the whole object from the db
|
||||
Document d = new Document(newId);
|
||||
|
||||
//event
|
||||
@@ -1396,24 +1409,30 @@ namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
base.setupNode();
|
||||
|
||||
IRecordsReader dr =
|
||||
using (var dr =
|
||||
SqlHelper.ExecuteReader("select published, documentUser, coalesce(templateId, cmsDocumentType.templateNodeId) as templateId, text, releaseDate, expireDate, updateDate from cmsDocument inner join cmsContent on cmsDocument.nodeId = cmsContent.Nodeid left join cmsDocumentType on cmsDocumentType.contentTypeNodeId = cmsContent.contentType and cmsDocumentType.IsDefault = 1 where versionId = @versionId",
|
||||
SqlHelper.CreateParameter("@versionId", Version));
|
||||
if (dr.Read())
|
||||
SqlHelper.CreateParameter("@versionId", Version)))
|
||||
{
|
||||
_creator = User;
|
||||
_writer = User.GetUser(dr.GetInt("documentUser"));
|
||||
if (dr.Read())
|
||||
{
|
||||
_creator = User;
|
||||
_writer = User.GetUser(dr.GetInt("documentUser"));
|
||||
|
||||
if (!dr.IsNull("templateId"))
|
||||
_template = dr.GetInt("templateId");
|
||||
if (!dr.IsNull("releaseDate"))
|
||||
_release = dr.GetDateTime("releaseDate");
|
||||
if (!dr.IsNull("expireDate"))
|
||||
_expire = dr.GetDateTime("expireDate");
|
||||
if (!dr.IsNull("updateDate"))
|
||||
_updated = dr.GetDateTime("updateDate");
|
||||
if (!dr.IsNull("templateId"))
|
||||
_template = dr.GetInt("templateId");
|
||||
if (!dr.IsNull("releaseDate"))
|
||||
_release = dr.GetDateTime("releaseDate");
|
||||
if (!dr.IsNull("expireDate"))
|
||||
_expire = dr.GetDateTime("expireDate");
|
||||
if (!dr.IsNull("updateDate"))
|
||||
_updated = dr.GetDateTime("updateDate");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException(string.Format("No Document exists with Version '{0}'", Version));
|
||||
}
|
||||
}
|
||||
dr.Close();
|
||||
|
||||
_published = HasPublishedVersion();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,9 +76,8 @@ namespace umbraco
|
||||
if (cms.businesslogic.member.Member.InUmbracoMemberMode() && TypeID != -1)
|
||||
{
|
||||
cms.businesslogic.member.MemberType dt = new cms.businesslogic.member.MemberType(TypeID);
|
||||
cms.businesslogic.member.Member m = cms.businesslogic.member.Member.MakeNew(name, dt, BusinessLogic.User.GetUser(_userID));
|
||||
m.Password = password;
|
||||
m.Email = email;
|
||||
cms.businesslogic.member.Member m = cms.businesslogic.member.Member.MakeNew(name, email, dt, BusinessLogic.User.GetUser(_userID));
|
||||
m.Password = password;
|
||||
m.LoginName = name.Replace(" ", "").ToLower();
|
||||
|
||||
NewMemberUIEventArgs e = new NewMemberUIEventArgs();
|
||||
|
||||
Reference in New Issue
Block a user