Exemplo n.º 1
0
		public void Create()
		{
			ResetDatabase();

			AuthorDao authorDao = (AuthorDao) Container[ typeof(AuthorDao) ];
			BlogDao blogDao = (BlogDao) Container[ typeof(BlogDao) ];
			PostDao postDao = (PostDao) Container[ typeof(PostDao) ];

			Author author = new Author("hamilton verissimo", "hammett", "mypass");
			Blog blog = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);
			
			Post post = new Post("My first entry", "This is my first entry", DateTime.Now);
			post.Blog = blog;

			authorDao.Create( author );
			blogDao.Create( blog );
			postDao.Create( post );

			IList posts = postDao.Find();
			Assert.AreEqual( 1, posts.Count );

			Post comparisson = (Post) posts[0];
			Assert.AreEqual( post.Title, comparisson.Title );
			Assert.AreEqual( post.Contents, comparisson.Contents );
		}
Exemplo n.º 2
0
		public Blog(String name, String description, String theme, Author author)
		{
			_name = name;
			_description = description;
			_theme = theme;
			_author = author;
		}
		public void CreateNewPostAndObtainPosts()
		{
			ResetDatabase();

			AccountService account = (AccountService) 
				Container[ typeof(AccountService) ];
			BlogService maintenance = (BlogService) 
				Container[ typeof(BlogService) ];

			Author author = new Author("hamilton verissimo", "hammett", "mypass");
			Blog blog = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);

			account.CreateAccountAndBlog(blog);
			
			Post post = maintenance.CreateNewPost( 
				blog, new Post("title", "contents", DateTime.Now) );

			Post comparisson = maintenance.ObtainPost( blog, post.Id );
			Assert.AreEqual( post.Id, comparisson.Id );
			Assert.AreEqual( post.Title, comparisson.Title );
			Assert.AreEqual( post.Contents, comparisson.Contents );

			IList posts = maintenance.ObtainPosts(blog);
			Assert.AreEqual( 1, posts.Count );
		}
Exemplo n.º 4
0
		public void FindAll()
		{
			ResetDatabase();

			AuthorDao authorDao = (AuthorDao) Container[ typeof(AuthorDao) ];
			BlogDao blogDao = (BlogDao) Container[ typeof(BlogDao) ];

			Author author = new Author("hamilton verissimo", "hammett", "mypass");
			Blog blog = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);

			authorDao.Create( author );
			blogDao.Create( blog );

			Post post1 = new Post("My first entry", "This is my first entry", DateTime.Now);
			post1.Blog = blog;
			Post post2 = new Post("My second entry", "This is my second entry", DateTime.Now);
			post2.Blog = blog;

			PostDao postDao = (PostDao) Container[ typeof(PostDao) ];
			postDao.Create(post1);
			postDao.Create(post2);

			IList posts = postDao.Find();
			Assert.AreEqual( 2, posts.Count );
		}
Exemplo n.º 5
0
		public void Update(Author author)
		{
			using(ISession session = sessionManager.OpenSession())
			{
				session.Update(author);
			}
		}
Exemplo n.º 6
0
		public Author Create(Author author)
		{
			using(ISession session = sessionManager.OpenSession())
			{
				if (author.Blogs == null)
				{
					author.Blogs = new ArrayList();
				}

				session.Save(author);
			}

			return author;
		}
Exemplo n.º 7
0
		public void FindAll()
		{
			ResetDatabase();

			AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];

			Author author1 = new Author("hamilton verissimo", "hammett", "mypass");
			Author author2 = new Author("john turturro", "turturro", "mypass");

			dao.Create( author1 );
			dao.Create( author2 );

			IList authors = dao.Find();
			Assert.AreEqual( 2, authors.Count );
		}
Exemplo n.º 8
0
		public void CreateAuthorAndBlog()
		{
			ResetDatabase();

			AccountService service = (AccountService) Container[ typeof(AccountService) ];

			Author author = new Author("hamilton verissimo", "hammett", "mypass");
			Blog blog = new Blog("hammett's blog", "Description", "default", author);

			service.CreateAccountAndBlog( blog );

			AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];
			Assert.AreEqual( 1, dao.Find().Count );
			BlogDao blogdao = (BlogDao) Container[ typeof(BlogDao) ];
			Assert.AreEqual( 1, blogdao.Find().Count );
		}
Exemplo n.º 9
0
		public void FindAll()
		{
			ResetDatabase();

			AuthorDao authorDao = (AuthorDao) Container[ typeof(AuthorDao) ];
			BlogDao blogDao = (BlogDao) Container[ typeof(BlogDao) ];

			Author author = new Author("hamilton verissimo", "hammett", "mypass");
			Blog blog1 = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);
			Blog blog2 = new Blog("hammett's personal blog", "more thoughts.. ugh!", "default", author);

			authorDao.Create( author );
			blogDao.Create( blog1 );
			blogDao.Create( blog2 );

			IList blogs = blogDao.Find();
			Assert.AreEqual( 2, blogs.Count );
		}
Exemplo n.º 10
0
		public void CreateAccount(String login, String name, String email,
		                      String pwd, String pwd2, String blogname,
		                      String blogdesc, String theme)
		{
			// Perform some simple validation
			if (!IsValid(login, name, email, pwd, pwd2, blogname, blogdesc, theme))
			{
				RenderView("new");
				return;
			}
 
			Author author = new Author(name, login, pwd);
			Blog blog = new Blog(blogname, blogdesc, theme, author);

			_accountService.CreateAccountAndBlog( blog );

			// Done, now lets log on into the system
			PerformLogin(login, pwd);
		}
Exemplo n.º 11
0
		public void Create()
		{
			ResetDatabase();

			AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];
			Assert.AreEqual( 0, dao.Find().Count );

			Author author = new Author("hamilton verissimo", "hammett", "mypass");

			dao.Create( author );

			IList authors = dao.Find();
			Assert.AreEqual( 1, authors.Count );

			Author comparisson = (Author) authors[0];
			Assert.AreEqual( author.Name, comparisson.Name );
			Assert.AreEqual( author.Login, comparisson.Login );
			Assert.AreEqual( author.Password, comparisson.Password );
		}
		public void TestAuthentication()
		{
			ResetDatabase();

			AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];

			Author author1 = new Author("hamilton verissimo", "hammett", "mypass");
			Author author2 = new Author("john turturro", "turturro", "otherpass");

			dao.Create( author1 );
			dao.Create( author2 );

			AuthenticationService authentication = (AuthenticationService) 
				Container[ typeof(AuthenticationService) ];

			Assert.IsTrue( authentication.Authenticate( "hammett", "mypass" ) );
			Assert.IsTrue( authentication.Authenticate( "turturro", "otherpass" ) );
			Assert.IsFalse( authentication.Authenticate( "hammett", "otherpass" ) );
			Assert.IsFalse( authentication.Authenticate( "hammett", "" ) );
			Assert.IsFalse( authentication.Authenticate( "turturro", "mypass" ) );
		}
Exemplo n.º 13
0
		public void Create()
		{
			ResetDatabase();

			AuthorDao authorDao = (AuthorDao) Container[ typeof(AuthorDao) ];
			BlogDao blogDao = (BlogDao) Container[ typeof(BlogDao) ];

			Author author = new Author("hamilton verissimo", "hammett", "mypass");
			Blog blog = new Blog("hammett's blog", "my thoughts.. ugh!", "default", author);

			authorDao.Create( author );
			blogDao.Create( blog );

			IList blogs = blogDao.Find();
			Assert.AreEqual( 1, blogs.Count );

			Blog comparisson = (Blog) blogs[0];
			Assert.AreEqual( blog.Name, comparisson.Name );
			Assert.AreEqual( blog.Description, comparisson.Description );
			Assert.AreEqual( blog.Theme, comparisson.Theme );
		}
Exemplo n.º 14
0
		public void Find()
		{
			ResetDatabase();

			AuthorDao dao = (AuthorDao) Container[ typeof(AuthorDao) ];

			Author author1 = new Author("hamilton verissimo", "hammett", "mypass");
			Author author2 = new Author("john turturro", "turturro", "mypass");

			dao.Create( author1 );
			dao.Create( author2 );

			Author found = dao.Find("hammett");
			Assert.IsNotNull(found);
			Assert.AreEqual( author1.Name, found.Name );
			Assert.AreEqual( author1.Login, found.Login );
			Assert.AreEqual( author1.Password, found.Password );

			found = dao.Find("turturro");
			Assert.IsNotNull(found);
			Assert.AreEqual( author2.Name, found.Name );
			Assert.AreEqual( author2.Login, found.Login );
			Assert.AreEqual( author2.Password, found.Password );
		}
Exemplo n.º 15
0
		public PrincipalAuthorAdapter(Author author)
		{
			_author = author;
		}
Exemplo n.º 16
0
		public virtual void UpdateAccount( Author author )
		{
			_authorDao.Update( author );
		}