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 PostTestCase
: BaseMindDumpTestCase
34 AuthorDao authorDao
= (AuthorDao
) Container
[ typeof(AuthorDao
) ];
35 BlogDao blogDao
= (BlogDao
) Container
[ typeof(BlogDao
) ];
36 PostDao postDao
= (PostDao
) Container
[ typeof(PostDao
) ];
38 Author author
= new Author("hamilton verissimo", "hammett", "mypass");
39 Blog blog
= new Blog("hammett's blog", "my thoughts.. ugh!", "default", author
);
41 Post post
= new Post("My first entry", "This is my first entry", DateTime
.Now
);
44 authorDao
.Create( author
);
45 blogDao
.Create( blog
);
46 postDao
.Create( post
);
48 IList posts
= postDao
.Find();
49 Assert
.AreEqual( 1, posts
.Count
);
51 Post comparisson
= (Post
) posts
[0];
52 Assert
.AreEqual( post
.Title
, comparisson
.Title
);
53 Assert
.AreEqual( post
.Contents
, comparisson
.Contents
);
61 AuthorDao authorDao
= (AuthorDao
) Container
[ typeof(AuthorDao
) ];
62 BlogDao blogDao
= (BlogDao
) Container
[ typeof(BlogDao
) ];
64 Author author
= new Author("hamilton verissimo", "hammett", "mypass");
65 Blog blog
= new Blog("hammett's blog", "my thoughts.. ugh!", "default", author
);
67 authorDao
.Create( author
);
68 blogDao
.Create( blog
);
70 Post post1
= new Post("My first entry", "This is my first entry", DateTime
.Now
);
72 Post post2
= new Post("My second entry", "This is my second entry", DateTime
.Now
);
75 PostDao postDao
= (PostDao
) Container
[ typeof(PostDao
) ];
76 postDao
.Create(post1
);
77 postDao
.Create(post2
);
79 IList posts
= postDao
.Find();
80 Assert
.AreEqual( 2, posts
.Count
);
84 public void FindBlogPosts()
88 AuthorDao authorDao
= (AuthorDao
) Container
[ typeof(AuthorDao
) ];
89 BlogDao blogDao
= (BlogDao
) Container
[ typeof(BlogDao
) ];
91 Author author
= new Author("hamilton verissimo", "hammett", "mypass");
92 Blog blog
= new Blog("hammett's blog", "my thoughts.. ugh!", "default", author
);
94 authorDao
.Create( author
);
95 blogDao
.Create( blog
);
97 Post post1
= new Post("My first entry", "This is my first entry", DateTime
.Now
);
99 Post post2
= new Post("My second entry", "This is my second entry", DateTime
.Now
);
102 PostDao postDao
= (PostDao
) Container
[ typeof(PostDao
) ];
103 postDao
.Create(post1
);
104 postDao
.Create(post2
);
106 IList posts
= postDao
.Find(blog
);
107 Assert
.AreEqual( 2, posts
.Count
);