Index: /branches/HeuristicLab.Services.Authentication Prototype/HeuristicLab.Services.Authentication Prototyp.vsmdi
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/HeuristicLab.Services.Authentication Prototyp.vsmdi (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/HeuristicLab.Services.Authentication Prototyp.vsmdi (revision 3943)
@@ -4,5 +4,17 @@
just first test for HeuristicLabUser
+
+
+
+
+
+
+
+
+
+
+
+
Index: /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.dbml
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.dbml (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.dbml (revision 3943)
@@ -4,32 +4,32 @@
-
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
Index: /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.dbml.layout
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.dbml.layout (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.dbml.layout (revision 3943)
@@ -27,5 +27,5 @@
-
+
@@ -33,5 +33,5 @@
-
+
@@ -45,5 +45,5 @@
-
+
@@ -52,5 +52,5 @@
-
+
Index: /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.designer.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.designer.cs (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.designer.cs (revision 3943)
@@ -2,9 +2,9 @@
//------------------------------------------------------------------------------
//
-// Dieser Code wurde von einem Tool generiert.
-// Laufzeitversion:2.0.50727.4927
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.4927
//
-// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
-// der Code erneut generiert wird.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
//------------------------------------------------------------------------------
@@ -144,5 +144,5 @@
[Column(Storage="_UserName", CanBeNull=false, UpdateCheck=UpdateCheck.Never)]
- public override string UserName
+ public virtual string UserName
{
get
@@ -173,5 +173,5 @@
[Column(Storage="_LastPasswordChangedDate", UpdateCheck=UpdateCheck.Never)]
- public override System.DateTime LastPasswordChangedDate
+ public virtual System.DateTime LastPasswordChangedDate
{
get
@@ -182,5 +182,5 @@
[Column(Storage="_PasswordQuestion", CanBeNull=false, UpdateCheck=UpdateCheck.Never)]
- public override string PasswordQuestion
+ public virtual string PasswordQuestion
{
get
@@ -211,5 +211,5 @@
[Column(Storage="_Email", CanBeNull=false)]
- public override string Email
+ public virtual string Email
{
get
@@ -231,5 +231,5 @@
[Column(Storage="_Comment", CanBeNull=false)]
- public override string Comment
+ public virtual string Comment
{
get
@@ -298,5 +298,5 @@
[Table(Name="")]
[InheritanceMapping(Code="permission", Type=typeof(HeuristicLabPermissionRole))]
- [InheritanceMapping(Code="role", Type=typeof(HeuristicLabRole))]
+ [InheritanceMapping(Code="role", Type=typeof(HeuristicLabRole), IsDefault=true)]
public abstract partial class HeuristicLabAbstractRole : INotifyPropertyChanging, INotifyPropertyChanged
{
@@ -312,7 +312,7 @@
private string _RoleType = default(string);
+ private EntitySet _HeuristicLabAbstractRole2;
+
private EntitySet _HeuristicLabUserRole;
-
- private EntitySet _HeuristicLabAbstractRole2;
private EntityRef _HeuristicLabAbstractRole1;
@@ -330,6 +330,6 @@
public HeuristicLabAbstractRole()
{
+ this._HeuristicLabAbstractRole2 = new EntitySet(new Action(this.attach_HeuristicLabAbstractRole2), new Action(this.detach_HeuristicLabAbstractRole2));
this._HeuristicLabUserRole = new EntitySet(new Action(this.attach_HeuristicLabUserRole), new Action(this.detach_HeuristicLabUserRole));
- this._HeuristicLabAbstractRole2 = new EntitySet(new Action(this.attach_HeuristicLabAbstractRole2), new Action(this.detach_HeuristicLabAbstractRole2));
this._HeuristicLabAbstractRole1 = default(EntityRef);
OnCreated();
@@ -394,4 +394,17 @@
}
+ [Association(Name="HeuristicLabAbstractRole_HeuristicLabAbstractRole", Storage="_HeuristicLabAbstractRole2", ThisKey="ID", OtherKey="ParentRoleID")]
+ public EntitySet HeuristicLabAbstractRole2
+ {
+ get
+ {
+ return this._HeuristicLabAbstractRole2;
+ }
+ set
+ {
+ this._HeuristicLabAbstractRole2.Assign(value);
+ }
+ }
+
[Association(Name="HeuristicLabAbstractRole_HeuristicLabUserRole", Storage="_HeuristicLabUserRole", ThisKey="ID", OtherKey="HeuristicLabRoleID")]
public EntitySet HeuristicLabUserRole
@@ -404,17 +417,4 @@
{
this._HeuristicLabUserRole.Assign(value);
- }
- }
-
- [Association(Name="HeuristicLabAbstractRole_HeuristicLabAbstractRole", Storage="_HeuristicLabAbstractRole2", ThisKey="ID", OtherKey="ParentRoleID")]
- public EntitySet HeuristicLabAbstractRole2
- {
- get
- {
- return this._HeuristicLabAbstractRole2;
- }
- set
- {
- this._HeuristicLabAbstractRole2.Assign(value);
}
}
@@ -474,4 +474,16 @@
}
+ private void attach_HeuristicLabAbstractRole2(HeuristicLabAbstractRole entity)
+ {
+ this.SendPropertyChanging();
+ entity.HeuristicLabAbstractRole1 = this;
+ }
+
+ private void detach_HeuristicLabAbstractRole2(HeuristicLabAbstractRole entity)
+ {
+ this.SendPropertyChanging();
+ entity.HeuristicLabAbstractRole1 = null;
+ }
+
private void attach_HeuristicLabUserRole(HeuristicLabUserRole entity)
{
@@ -484,16 +496,4 @@
this.SendPropertyChanging();
entity.HeuristicLabAbstractRole = null;
- }
-
- private void attach_HeuristicLabAbstractRole2(HeuristicLabAbstractRole entity)
- {
- this.SendPropertyChanging();
- entity.HeuristicLabAbstractRole1 = this;
- }
-
- private void detach_HeuristicLabAbstractRole2(HeuristicLabAbstractRole entity)
- {
- this.SendPropertyChanging();
- entity.HeuristicLabAbstractRole1 = null;
}
}
Index: /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DatabaseUtil.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DatabaseUtil.cs (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Persistence/DatabaseUtil.cs (revision 3943)
@@ -1,13 +1,42 @@
-namespace Persistence {
+using System;
+
+namespace Persistence {
///
- ///
+ /// combines multiple used static methods into one class
///
public class DatabaseUtil {
///
- ///
+ /// creates and returns a database connection, if possible
///
- ///
+ /// database connection (could be null)
public static DataClassesDataContext createDataClassesDataContext() {
- return new Persistence.DataClassesDataContext(@"C:\TEMP\HeuristicLabTemp.mdf");
+ DataClassesDataContext db;
+ try {
+ db = new Persistence.DataClassesDataContext(@"C:\TEMP\HeuristicLabTemp.mdf");
+ }
+ catch (Exception) {
+ return null;
+ }
+ return db;
+ }
+
+ ///
+ /// creates a new database out of the LINQ to SQL classes
+ ///
+ /// DataClassesDataContext
+ public static void createDatabase(DataClassesDataContext db) {
+ if (db == null) {
+ throw new ArgumentNullException("db");
+ }
+
+ if (db.DatabaseExists()) {
+ Console.WriteLine("Deleting old database...");
+ db.DeleteDatabase();
+ Console.WriteLine("Deleted old database!");
+ }
+
+ Console.WriteLine("Creating new database...");
+ db.CreateDatabase();
+ Console.WriteLine("Created new database!");
}
}
Index: /branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUser.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUser.cs (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUser.cs (revision 3943)
@@ -3,5 +3,18 @@
namespace Persistence {
+ ///
+ /// implements the MembershipUser for HeuristicLab
+ ///
partial class HeuristicLabUser : MembershipUser {
+ public HeuristicLabUser(string name, string email, string passwordQuestion, string comment) : this() {
+ _UserName = name;
+ Password = "INIT"; // just for tests
+ _LastPasswordChangedDate = System.DateTime.Today;
+ _PasswordQuestion = passwordQuestion;
+ PasswordAnswer = "";
+ Email = email;
+ Comment = comment;
+ }
+
public override bool ChangePassword(string oldPassword, string newPassword) {
if (oldPassword == null) {
Index: /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs (revision 3943)
@@ -1,7 +1,6 @@
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Web.Security;
+using Persistence;
namespace Service.Provider {
@@ -17,5 +16,20 @@
public override bool ChangePassword(string username, string oldPassword, string newPassword) {
- throw new NotImplementedException();
+ DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
+ if (db == null) {
+ return false;
+ }
+ try {
+ HeuristicLabUser u = db.HeuristicLabUsers.Single(x => x.UserName == username);
+ if (u.ChangePassword(oldPassword, newPassword)) {
+ db.SubmitChanges();
+ return true;
+ } else {
+ return false;
+ }
+ }
+ catch (Exception) {
+ return false;
+ }
}
Index: /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs (revision 3943)
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.Web.Security;
+using Persistence;
namespace Service.Provider {
Index: /branches/HeuristicLab.Services.Authentication Prototype/Service/Service.csproj
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Service/Service.csproj (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Service/Service.csproj (revision 3943)
@@ -38,4 +38,7 @@
+
+ 3.5
+
3.0
@@ -74,3 +77,12 @@
-->
+
+
+
+
+ True
+
+
+
+
Index: /branches/HeuristicLab.Services.Authentication Prototype/Service/Service.csproj.user
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/Service/Service.csproj.user (revision 3943)
+++ /branches/HeuristicLab.Services.Authentication Prototype/Service/Service.csproj.user (revision 3943)
@@ -0,0 +1,14 @@
+
+
+
+
+
+ RunFiles
+
+
+ False
+
+
+
+
+
Index: /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/AbstractHeuristicLabTest.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/AbstractHeuristicLabTest.cs (revision 3943)
+++ /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/AbstractHeuristicLabTest.cs (revision 3943)
@@ -0,0 +1,49 @@
+using Persistence;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+
+namespace UnitTests {
+ ///
+ ///This is a abstract test class for all HeuristicLab unit tests
+ ///
+ public abstract class AbstractHeuristicLabTest {
+
+ ///
+ /// shared database for all test methods
+ ///
+ protected Persistence.DataClassesDataContext db;
+
+ ///
+ /// constructor creates database connection for all other test methods
+ ///
+ public AbstractHeuristicLabTest() {
+ db = Persistence.DatabaseUtil.createDataClassesDataContext();
+ }
+
+ ///
+ /// creates and opens a local database our of the DataClasses
+ ///
+ [TestMethod()]
+ public virtual void createDBTest() {
+ Assert.IsNotNull(db);
+
+ DatabaseUtil.createDatabase(db);
+
+ Assert.AreEqual(System.Data.ConnectionState.Open, db.Connection.State);
+ }
+
+ ///
+ /// checks if the database connection is open
+ /// should be used by all other test methods
+ ///
+ protected virtual void checkConnection() {
+ Assert.IsNotNull(db);
+
+ if (db.Connection.State != System.Data.ConnectionState.Open) {
+ db.Connection.Open();
+ }
+
+ Assert.AreEqual(System.Data.ConnectionState.Open, db.Connection.State);
+ }
+ }
+}
Index: /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs (revision 3943)
@@ -4,6 +4,4 @@
namespace UnitTests {
-
-
///
///Dies ist eine Testklasse für "HeuristicLabMembershipProviderTest" und soll
@@ -11,7 +9,5 @@
///
[TestClass()]
- public class HeuristicLabMembershipProviderTest {
-
-
+ public class HeuristicLabMembershipProviderTest : AbstractHeuristicLabTest {
private TestContext testContextInstance;
@@ -59,5 +55,4 @@
#endregion
-
///
///Ein Test für "RequiresUniqueEmail"
Index: /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs (revision 3943)
@@ -2,6 +2,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTests {
-
-
///
///Dies ist eine Testklasse für "HeuristicLabRoleProviderTest" und soll
@@ -9,7 +7,5 @@
///
[TestClass()]
- public class HeuristicLabRoleProviderTest {
-
-
+ public class HeuristicLabRoleProviderTest : AbstractHeuristicLabTest {
private TestContext testContextInstance;
@@ -57,5 +53,4 @@
#endregion
-
///
///Ein Test für "ApplicationName"
Index: /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabUserTest.cs
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabUserTest.cs (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabUserTest.cs (revision 3943)
@@ -1,5 +1,7 @@
-using Persistence;
+using System;
+using System.Collections.Generic;
+using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
+using Persistence;
namespace UnitTests {
@@ -9,41 +11,41 @@
///
[TestClass()]
- public class HeuristicLabUserTest {
+ public class HeuristicLabUserTest : AbstractHeuristicLabTest {
private TestContext testContextInstance;
- private Persistence.DataClassesDataContext db;
-
- public HeuristicLabUserTest() {
- db = Persistence.DatabaseUtil.createDataClassesDataContext();
- }
-
- ///
- /// creates a local database for all other test methods
+ ///
+ /// inserts, modifies and deletes a new user into the database
///
[TestMethod()]
- public void createDBTest() {
- if (db.DatabaseExists()) {
- Console.WriteLine("Deleting old database...");
- db.DeleteDatabase();
- Console.WriteLine("Deleted old database!");
- }
- Console.WriteLine("Creating new database...");
- db.CreateDatabase();
- Console.WriteLine("Created new database!");
- }
-
- ///
- /// inserts a new user into the database
- ///
- [TestMethod()]
- public void addUserTest() {
- //Assert.IsNotNull(db);
-
- //Persistence.HeuristicLabUser user = new HeuristicLabUser();
- //user.UserName = "TEST";
- //db.HeuristicLabUsers.InsertOnSubmit(user);
- //db.SubmitChanges();
-
-// db.HeuristicLabUsers.
+ public void modifyUserTest() {
+ checkConnection();
+
+ // insert new user
+ Persistence.HeuristicLabUser user = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ db.HeuristicLabUsers.InsertOnSubmit(user);
+ db.SubmitChanges();
+ Persistence.HeuristicLabUser u = db.HeuristicLabUsers.Single(x => x.UserName == "testname");
+ Assert.IsNotNull(u);
+ Assert.AreEqual("testname", u.UserName);
+ Assert.AreEqual("testemail", u.Email);
+ Assert.AreEqual("testquestion", u.PasswordQuestion);
+ Assert.AreEqual("testcomment", u.Comment);
+
+ // modify existing user
+ u.Email = "testemail2";
+ u.Comment = "testcomment2";
+ db.SubmitChanges();
+ u = db.HeuristicLabUsers.Single(x => x.UserName == "testname");
+ Assert.IsNotNull(u);
+ Assert.AreEqual("testname", u.UserName);
+ Assert.AreEqual("testemail2", u.Email);
+ Assert.AreEqual("testquestion", u.PasswordQuestion);
+ Assert.AreEqual("testcomment2", u.Comment);
+
+ // delete user
+ db.HeuristicLabUsers.DeleteOnSubmit(u);
+ db.SubmitChanges();
+ List uList = db.HeuristicLabUsers.Where(x => x.UserName == "testname").ToList();
+ Assert.AreEqual(0, uList.Count);
}
@@ -91,5 +93,4 @@
#endregion
-
///
///A test for UserName
@@ -97,112 +98,92 @@
[TestMethod()]
public void UserNameTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string actual;
- actual = target.UserName;
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("testname", target.UserName);
+ }
+
+ ///
+ ///A test for PasswordQuestion
+ ///
+ [TestMethod()]
+ public void PasswordQuestionTest() {
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("testquestion", target.PasswordQuestion);
+ target.ChangePasswordQuestionAndAnswer("INIT", "newquestion", "newanswer");
+ Assert.AreEqual("newquestion", target.PasswordQuestion);
+ }
+
+ ///
+ ///A test for PasswordAnswer
+ ///
+ [TestMethod()]
+ public void PasswordAnswerTest() {
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("", target.PasswordAnswer);
+ target.ChangePasswordQuestionAndAnswer("INIT", "newquestion", "newanswer");
+ Assert.AreEqual("newquestion", target.PasswordQuestion);
+ target.PasswordAnswer = "testanswer";
+ Assert.AreEqual("testanswer", target.PasswordAnswer);
+ }
+
+ ///
+ ///A test for Password
+ ///
+ [TestMethod()]
+ public void PasswordTest() {
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("INIT", target.Password);
+ target.ChangePassword(target.Password, "pwd1");
+ Assert.AreEqual("pwd1", target.Password);
+ target.ChangePassword("pwd1", "pwd2");
+ Assert.AreEqual("pwd2", target.Password);
+ }
+
+ ///
+ ///A test for LastPasswordChangedDate
+ ///
+ [TestMethod()]
+ public void LastPasswordChangedDateTest() {
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual(System.DateTime.Today, target.LastPasswordChangedDate);
+ target.ChangePassword(target.Password, "pwd1");
+ Assert.AreEqual(System.DateTime.Today, target.LastPasswordChangedDate);
+ }
+
+ ///
+ ///A test for Email
+ ///
+ [TestMethod()]
+ public void EmailTest() {
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("testemail", target.Email);
+ target.Email = "testemail2";
+ Assert.AreEqual("testemail2", target.Email);
+ }
+
+ ///
+ ///A test for Comment
+ ///
+ [TestMethod()]
+ public void CommentTest() {
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ target.Comment = "testcomment2";
+ Assert.AreEqual("testcomment2", target.Comment);
+ }
+
+ ///
+ ///A test for UnlockUser
+ ///
+ [TestMethod()]
+ public void UnlockUserTest() {
Assert.Inconclusive("Verify the correctness of this test method.");
}
///
- ///A test for PasswordQuestion
- ///
- [TestMethod()]
- public void PasswordQuestionTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string actual;
- actual = target.PasswordQuestion;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for PasswordAnswer
- ///
- [TestMethod()]
- public void PasswordAnswerTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string expected = string.Empty; // TODO: Initialize to an appropriate value
- string actual;
- target.PasswordAnswer = expected;
- actual = target.PasswordAnswer;
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Password
- ///
- [TestMethod()]
- public void PasswordTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // 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 LastPasswordChangedDate
- ///
- [TestMethod()]
- public void LastPasswordChangedDateTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- DateTime actual;
- actual = target.LastPasswordChangedDate;
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for Email
- ///
- [TestMethod()]
- public void EmailTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // 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 Comment
- ///
- [TestMethod()]
- public void CommentTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string expected = string.Empty; // TODO: Initialize to an appropriate value
- string actual;
- target.Comment = expected;
- actual = target.Comment;
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
- ///A test for UnlockUser
- ///
- [TestMethod()]
- public void UnlockUserTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.UnlockUser();
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
- }
-
- ///
///A test for ToString
///
[TestMethod()]
public void ToStringTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string expected = string.Empty; // TODO: Initialize to an appropriate value
- string actual;
- actual = target.ToString();
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("testname", target.ToString());
}
@@ -235,10 +216,9 @@
[TestMethod()]
public void ResetPasswordTest1() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string expected = string.Empty; // TODO: Initialize to an appropriate value
- string actual;
- actual = target.ResetPassword();
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ target.ChangePassword(target.Password, "pwd1");
+ Assert.AreEqual("pwd1", target.GetPassword());
+ target.ResetPassword();
+ Assert.AreEqual("", target.GetPassword());
}
@@ -248,11 +228,9 @@
[TestMethod()]
public void ResetPasswordTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string passwordAnswer = string.Empty; // TODO: Initialize to an appropriate value
- string expected = string.Empty; // TODO: Initialize to an appropriate value
- string actual;
- actual = target.ResetPassword(passwordAnswer);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ target.ChangePassword(target.Password, "pwd1");
+ Assert.AreEqual("pwd1", target.GetPassword());
+ target.ResetPassword("wrongAnswer");
+ Assert.AreEqual("pwd1", target.GetPassword());
}
@@ -262,11 +240,12 @@
[TestMethod()]
public void GetPasswordTest1() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string passwordAnswer = string.Empty; // TODO: Initialize to an appropriate value
- string expected = string.Empty; // TODO: Initialize to an appropriate value
- string actual;
- actual = target.GetPassword(passwordAnswer);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ target.PasswordAnswer = "answer";
+ Assert.AreEqual("", target.GetPassword("answer"));
+ target.ChangePassword(target.Password, "pwd1");
+ Assert.AreEqual("pwd1", target.GetPassword("answer"));
+ target.ChangePassword("pwd1", "pwd2");
+ Assert.AreEqual("pwd2", target.GetPassword("answer"));
+ Assert.AreEqual("", target.GetPassword("wrong"));
}
@@ -276,10 +255,10 @@
[TestMethod()]
public void GetPasswordTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string expected = string.Empty; // TODO: Initialize to an appropriate value
- string actual;
- actual = target.GetPassword();
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("INIT", target.GetPassword());
+ target.ChangePassword(target.Password, "pwd1");
+ Assert.AreEqual("pwd1", target.GetPassword());
+ target.ChangePassword("pwd1", "pwd2");
+ Assert.AreEqual("pwd2", target.GetPassword());
}
@@ -289,13 +268,10 @@
[TestMethod()]
public void ChangePasswordQuestionAndAnswerTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string password = string.Empty; // TODO: Initialize to an appropriate value
- string newPasswordQuestion = string.Empty; // TODO: Initialize to an appropriate value
- string newPasswordAnswer = string.Empty; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.ChangePasswordQuestionAndAnswer(password, newPasswordQuestion, newPasswordAnswer);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("testquestion", target.PasswordQuestion);
+ Assert.AreEqual("", target.PasswordAnswer);
+ target.ChangePasswordQuestionAndAnswer("INIT", "newquestion", "newanswer");
+ Assert.AreEqual("newquestion", target.PasswordQuestion);
+ Assert.AreEqual("newanswer", target.PasswordAnswer);
}
@@ -305,12 +281,16 @@
[TestMethod()]
public void ChangePasswordTest() {
- HeuristicLabUser target = new HeuristicLabUser(); // TODO: Initialize to an appropriate value
- string oldPassword = string.Empty; // TODO: Initialize to an appropriate value
- string newPassword = string.Empty; // TODO: Initialize to an appropriate value
- bool expected = false; // TODO: Initialize to an appropriate value
- bool actual;
- actual = target.ChangePassword(oldPassword, newPassword);
- Assert.AreEqual(expected, actual);
- Assert.Inconclusive("Verify the correctness of this test method.");
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("INIT", target.Password);
+ target.ChangePassword(target.Password, "pwd1");
+ Assert.AreEqual("pwd1", target.Password);
+ target.ChangePassword("pwd1", "pwd2");
+ Assert.AreEqual("pwd2", target.Password);
+ try {
+ target.ChangePassword("abc", "def");
+ Assert.Fail();
+ }
+ catch (Exception) {
+ }
}
@@ -320,6 +300,12 @@
[TestMethod()]
public void HeuristicLabUserConstructorTest() {
- HeuristicLabUser target = new HeuristicLabUser();
- Assert.Inconclusive("TODO: Implement code to verify target");
+ HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
+ Assert.AreEqual("testname", target.UserName);
+ Assert.AreEqual("INIT", target.Password);
+ Assert.AreEqual(System.DateTime.Today, target.LastPasswordChangedDate);
+ Assert.AreEqual("testquestion", target.PasswordQuestion);
+ Assert.AreEqual("", target.PasswordAnswer);
+ Assert.AreEqual("testemail", target.Email);
+ Assert.AreEqual("testcomment", target.Comment);
}
}
Index: /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/UnitTests.csproj
===================================================================
--- /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/UnitTests.csproj (revision 3942)
+++ /branches/HeuristicLab.Services.Authentication Prototype/UnitTests/UnitTests.csproj (revision 3943)
@@ -58,4 +58,5 @@
+