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); }
public void FindBlogPosts() { 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(blog); Assert.AreEqual(2, posts.Count); }
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); }
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); }
public virtual void CreateAccountAndBlog(Blog blog) { _authorDao.Create(blog.Author); _blogDao.Create(blog); if (EventPublisher != null) { EventPublisher.NotifyBlogAdded(blog); } }
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")); }
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); }
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 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); }