public void CreateArticleTestWithInvalidDateTime()
 {
     SteveDelezioSEAssignment2Sit1.MyService.ServiceManager ms = new SteveDelezioSEAssignment2Sit1.MyService.ServiceManager();
     DataContext db = new DataContext();
     int intialCount = db.tbl_Articles.Count();
     ms.CreateArticle("TestingTitle", "TestingContent", "TestinComment", DateTime.Parse("23/01/2015"), 2, 3, 5, 1);
     int FinalCount = db.tbl_Articles.Count();
     Assert.AreEqual(intialCount, FinalCount);
 }
 public void CreateArticleTestWithEmptyTitle()
 {
     SteveDelezioSEAssignment2Sit1.MyService.ServiceManager ms = new SteveDelezioSEAssignment2Sit1.MyService.ServiceManager();
     DataContext db = new DataContext();
     int intialCount = db.tbl_Articles.Count();
     ms.CreateArticle(String.Empty, "TestingContent", "TestinComment", DateTime.Now, 2, 3, 5, 1);
     int FinalCount = db.tbl_Articles.Count();
     Assert.AreEqual(intialCount, FinalCount);
 }
        public void DeleteArticle()
        {
            SteveDelezioSEAssignment2Sit1.MyService.ServiceManager ms = new SteveDelezioSEAssignment2Sit1.MyService.ServiceManager();
            DataContext db = new DataContext();
            int initialCount = db.tbl_Articles.Count();

            ms.DeleteArticle(12);
            int FinalCount = db.tbl_Articles.Count();
            Assert.AreEqual(initialCount - 1, FinalCount);
        }
        public void DeleteArticleNonExistingArticle()
        {
            DataContext db = new DataContext();
            int initialCount = db.tbl_Articles.Count();
            SteveDelezioSEAssignment2Sit1.MyService.ServiceManager ms =
                new SteveDelezioSEAssignment2Sit1.MyService.ServiceManager();
            try
            {
                ms.DeleteArticle(950);
            }
            finally
            {

                int FinalCount = db.tbl_Articles.Count();

                Assert.AreEqual(initialCount, FinalCount);
            }
        }
 public void UpdateRoleWithNull()
 {
     RolesController rc = new RolesController();
     DataContext db = new DataContext();
     rc.UpdateRole(null);
 }
        public void UpdateRole()
        {
            RolesController rc = new RolesController();
            DataContext db = new DataContext();
            tbl_Roles r = new tbl_Roles();
            {
                r.RoleId = 2;
                r.RoleName = "Tester";

            }
            rc.UpdateRole(r);
            tbl_Roles FinalRole = db.tbl_Roles.Find(2);
            Assert.AreEqual("Tester",FinalRole.RoleName);
            Assert.AreEqual(2,FinalRole.RoleId);
        }
        public void DeleteArticleWithInvalidId()
        {
            int initialCount = 0;
            int FinalCount = 0;
            DataContext db = new DataContext();
            try
            {
                SteveDelezioSEAssignment2Sit1.MyService.ServiceManager ms =
                    new SteveDelezioSEAssignment2Sit1.MyService.ServiceManager();

                 initialCount = db.tbl_Articles.Count();

                ms.DeleteArticle(-12);

            }
            finally
            {
                FinalCount = db.tbl_Articles.Count();
                Assert.AreEqual(initialCount, FinalCount);
            }
        }
        public void UpdateArticleEmptyTitle()
        {
            SteveDelezioSEAssignment2Sit1.MyService.ServiceManager ms = new SteveDelezioSEAssignment2Sit1.MyService.ServiceManager();
            DataContext db = new DataContext();
            tbl_Articles unupdated = db.tbl_Articles.SingleOrDefault(x => x.ArticleId == 12);
            string unupdatedTitle = unupdated.ArticleTitle;
            string unupdatedContent = unupdated.ArticleContent;
            string unupdatedComments = unupdated.ArticleComments;
            ms.UpdateArticle(String.Empty, "UpdatedContent", "UpdatedComment", DateTime.Now, unupdated.UserId, unupdated.ArticleMediaManagerId, unupdated.ArticleStatusId, unupdated.ArticleStateId, unupdated.ArticleId);
            db.Entry(unupdated).Reload();

            tbl_Articles updated = db.tbl_Articles.SingleOrDefault(x => x.ArticleId == 12);
            Assert.AreEqual(unupdated.ArticleId, updated.ArticleId);
            Assert.AreEqual(unupdatedTitle, updated.ArticleTitle);
            Assert.AreEqual(unupdatedContent, updated.ArticleContent);
            Assert.AreEqual(unupdatedComments, updated.ArticleComments);
        }
 public void ReadArticleWithWrongId()
 {
     SteveDelezioSEAssignment2Sit1.MyService.ServiceManager ms = new SteveDelezioSEAssignment2Sit1.MyService.ServiceManager();
     DataContext db = new DataContext();
     ArticlesController ac = new ArticlesController();
     tbl_Articles testarticle = new tbl_Articles();
     try
     {
         testarticle = ac.GetArticleById(-11);
     }
     finally
     {
         Assert.AreEqual(String.Empty, testarticle.ArticleContent);
     }
 }
 public void ReadArticle()
 {
     SteveDelezioSEAssignment2Sit1.MyService.ServiceManager ms = new SteveDelezioSEAssignment2Sit1.MyService.ServiceManager();
     DataContext db = new DataContext();
     // ArticlesController r = new ArticlesController();
     //  r.Details(5);
 }