1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 using System
.Collections
;
20 using Castle
.Applications
.MindDump
.Dao
;
21 using Castle
.Applications
.MindDump
.Model
;
23 using NUnit
.Framework
;
27 public class AuthorTestCase
: BaseMindDumpTestCase
34 AuthorDao dao
= (AuthorDao
) Container
[ typeof(AuthorDao
) ];
35 Assert
.AreEqual( 0, dao
.Find().Count
);
37 Author author
= new Author("hamilton verissimo", "hammett", "mypass");
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
);
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
);
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
);