Reverted accidental checkin
[castle.git] / Samples / MindDump / Castle.Applications.MindDump.Tests / AuthorTestCase.cs
blob0532ff102b5d12db63923327f1a6518369f8f5cf
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;
18 using System.Collections;
20 using Castle.Applications.MindDump.Dao;
21 using Castle.Applications.MindDump.Model;
23 using NUnit.Framework;
26 [TestFixture]
27 public class AuthorTestCase : BaseMindDumpTestCase
29 [Test]
30 public void Create()
32 ResetDatabase();
34 AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];
35 Assert.AreEqual( 0, dao.Find().Count );
37 Author author = new Author("hamilton verissimo", "hammett", "mypass");
39 dao.Create( author );
41 IList authors = dao.Find();
42 Assert.AreEqual( 1, authors.Count );
44 Author comparisson = (Author) authors[0];
45 Assert.AreEqual( author.Name, comparisson.Name );
46 Assert.AreEqual( author.Login, comparisson.Login );
47 Assert.AreEqual( author.Password, comparisson.Password );
50 [Test]
51 public void FindAll()
53 ResetDatabase();
55 AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];
57 Author author1 = new Author("hamilton verissimo", "hammett", "mypass");
58 Author author2 = new Author("john turturro", "turturro", "mypass");
60 dao.Create( author1 );
61 dao.Create( author2 );
63 IList authors = dao.Find();
64 Assert.AreEqual( 2, authors.Count );
67 [Test]
68 public void Find()
70 ResetDatabase();
72 AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];
74 Author author1 = new Author("hamilton verissimo", "hammett", "mypass");
75 Author author2 = new Author("john turturro", "turturro", "mypass");
77 dao.Create( author1 );
78 dao.Create( author2 );
80 Author found = dao.Find("hammett");
81 Assert.IsNotNull(found);
82 Assert.AreEqual( author1.Name, found.Name );
83 Assert.AreEqual( author1.Login, found.Login );
84 Assert.AreEqual( author1.Password, found.Password );
86 found = dao.Find("turturro");
87 Assert.IsNotNull(found);
88 Assert.AreEqual( author2.Name, found.Name );
89 Assert.AreEqual( author2.Login, found.Login );
90 Assert.AreEqual( author2.Password, found.Password );