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 { /// ///This is a test class for MemberTest and is intended ///to contain all MemberTest Unit Tests /// [TestClass()] public class MemberTest { /// /// Creates a new member type and member, then deletes it /// [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)); } /// ///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 /// [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(mg.Id, ((MemberGroup)m.Groups.Cast().First().Value).Id); //remove the grup association 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 ///// /////A test for Member Constructor ///// //[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"); //} ///// /////A test for Member Constructor ///// //[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"); //} ///// /////A test for Member Constructor ///// //[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"); //} ///// /////A test for Member Constructor ///// //[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"); //} ///// /////A test for AddMemberToCache ///// //[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."); //} ///// /////A test for AddMemberToCache ///// //[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."); //} ///// /////A test for CachedMembers ///// //[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."); //} ///// /////A test for ChangePassword ///// //[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."); //} ///// /////A test for ClearMemberFromClient ///// //[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."); //} ///// /////A test for ClearMemberFromClient ///// //[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."); //} ///// /////A test for CurrentMemberId ///// //[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."); //} ///// /////A test for DeleteFromType ///// //[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."); //} ///// /////A test for GetCurrentMember ///// //[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."); //} ///// /////A test for GetMemberByName ///// //[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."); //} ///// /////A test for GetMemberFromCache ///// //[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."); //} ///// /////A test for GetMemberFromEmail ///// //[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."); //} ///// /////A test for GetMemberFromLoginAndEncodedPassword ///// //[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."); //} ///// /////A test for GetMemberFromLoginName ///// //[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."); //} ///// /////A test for GetMemberFromLoginNameAndPassword ///// //[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."); //} ///// /////A test for InUmbracoMemberMode ///// //[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."); //} ///// /////A test for IsLoggedOn ///// //[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."); //} ///// /////A test for IsMember ///// //[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."); //} ///// /////A test for IsUsingUmbracoRoles ///// //[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."); //} ///// /////A test for MakeNew ///// //[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."); //} ///// /////A test for RemoveGroup ///// //[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."); //} ///// /////A test for RemoveMemberFromCache ///// //[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."); //} ///// /////A test for RemoveMemberFromCache ///// //[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."); //} ///// /////A test for Save ///// //[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."); //} ///// /////A test for ToXml ///// //[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."); //} ///// /////A test for XmlGenerate ///// //[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."); //} ///// /////A test for getAllOtherMembers ///// //[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."); //} ///// /////A test for getMemberFromFirstLetter ///// //[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."); //} ///// /////A test for Email ///// //[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."); //} ///// /////A test for GetAll ///// //[TestMethod()] //public void GetAllTest() //{ // Member[] actual; // actual = Member.GetAll; // Assert.Inconclusive("Verify the correctness of this test method."); //} ///// /////A test for Groups ///// //[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."); //} ///// /////A test for LoginName ///// //[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."); //} ///// /////A test for Password ///// //[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."); //} ///// /////A test for Text ///// //[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 } }