Reverted accidental checkin
[castle.git] / Samples / MindDump / Castle.Applications.MindDump.Tests / AuthenticationServiceTestCase.cs
blob94c21850235411c0b7b8dfb2c330abcdebe48b54
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.MindDump.Tests
17 using System;
19 using NUnit.Framework;
21 using Castle.Applications.MindDump.Dao;
22 using Castle.Applications.MindDump.Model;
23 using Castle.Applications.MindDump.Services;
26 [TestFixture]
27 public class AuthenticationServiceTestCase : BaseMindDumpTestCase
29 [Test]
30 public void TestAuthentication()
32 ResetDatabase();
34 AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];
36 Author author1 = new Author("hamilton verissimo", "hammett", "mypass");
37 Author author2 = new Author("john turturro", "turturro", "otherpass");
39 dao.Create( author1 );
40 dao.Create( author2 );
42 AuthenticationService authentication = (AuthenticationService)
43 Container[ typeof(AuthenticationService) ];
45 Assert.IsTrue( authentication.Authenticate( "hammett", "mypass" ) );
46 Assert.IsTrue( authentication.Authenticate( "turturro", "otherpass" ) );
47 Assert.IsFalse( authentication.Authenticate( "hammett", "otherpass" ) );
48 Assert.IsFalse( authentication.Authenticate( "hammett", "" ) );
49 Assert.IsFalse( authentication.Authenticate( "turturro", "mypass" ) );