Added RedirectUsingNamedRoute
[castle.git] / Samples / PestControl / Castle.Applications.PestControl.Tests / Model / UsersTestCase.cs
blobde1694bb40d6b927a027c389753f46b1494589c7
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Applications.PestControl.Tests.Model
17 using System;
19 using NUnit.Framework;
21 using Castle.Applications.PestControl.Model;
23 /// <summary>
24 /// Summary description for UsersTestCase.
25 /// </summary>
26 [TestFixture]
27 public class UsersTestCase : AbstractPestControlTestCase
29 [Test]
30 public void CreateUser()
32 Assert.AreEqual( 0, _model.Users.Count );
34 _engine.ExecuteCommand( new CreateUserCommand("admin", "pass123", "admin@admin.com") );
36 Assert.AreEqual( 1, _model.Users.Count );
39 [Test]
40 public void Authenticate()
42 _engine.ExecuteCommand( new CreateUserCommand("admin", "pass1", "admin@nowhere.com") );
43 _engine.ExecuteCommand( new CreateUserCommand("hammett", "pass2", "hammett@nowhere.com") );
44 _engine.ExecuteCommand( new CreateUserCommand("joe", "pass3", "joe@nowhere.com") );
46 Assert.IsTrue( _model.Users.Authenticate( "admin@nowhere.com", "pass1" ) );
47 Assert.IsFalse( _model.Users.Authenticate( "admin@nowhere.com", "pass2" ) );
48 Assert.IsTrue( _model.Users.Authenticate( "joe@nowhere.com", "pass3" ) );
51 [Test]
52 public void FindByEmail()
54 _engine.ExecuteCommand( new CreateUserCommand("admin", "pass123", "admin@nowhere.com") );
55 _engine.ExecuteCommand( new CreateUserCommand("hammett", "pass123", "hammett@nowhere.com") );
56 _engine.ExecuteCommand( new CreateUserCommand("joe", "pass123", "joe@nowhere.com") );
58 Assert.IsNotNull( _model.Users.FindByEmail("admin@nowhere.com") );
59 Assert.IsNotNull( _model.Users.FindByEmail("hammett@nowhere.com") );
60 Assert.IsNotNull( _model.Users.FindByEmail("joe@nowhere.com") );
62 Assert.AreEqual( "admin",_model.Users.FindByEmail("admin@nowhere.com").Name );
63 Assert.AreEqual( "joe",_model.Users.FindByEmail("joe@nowhere.com").Name );
64 Assert.AreEqual( "hammett",_model.Users.FindByEmail("hammett@nowhere.com").Name );