public static void CleanDataBaseStart(TestContext tc) { controller = Controller.GetInstance(); for (int i = 0; i < interval; i++) { testchannelnames.Add(testchannelname + i); testchanneldescrs.Add(testchanneldescr + i); } }
public void Controller_DeleteUser_Parameter_Valid() { controller = Controller.GetInstance(); testId = TestExtensions._testUser1.Id; try { controller.DeleteUser(testId); User user = _dao.GetUser(testId); Assert.Fail("No exception was thrown. "); } catch { //This is expected testId = int.MaxValue; } }
public void Controller_DeleteUser_Parameter_Neg() { controller = Controller.GetInstance(); testId = TestExtensions._testUser1.Id; try { controller.DeleteUser(-1); Assert.Fail("No exception was thrown"); } catch (ArgumentException) { //This is expected } }
public void Controller_UpdateUser_State_NothingUpdated() { controller = Controller.GetInstance(); RentItServer.ITU.DatabaseWrapperObjects.User user = TestExtensions._testUser1; try { controller.UpdateUser(user.Id, null, null, null); User updatedUser = _dao.GetUser(user.Id); Assert.IsTrue(user.Username.Equals(updatedUser.Username)); Assert.IsTrue(user.Email.Equals(updatedUser.Email)); } catch (Exception e) { Assert.Fail("An exception was thrown. " + e); } }
public void Controller_GetChannelsWithFilter_State_SortNumberOfCommentsDescending() { controller = Controller.GetInstance(); ChannelSearchArgs csa = controller.GetDefaultChannelSearchArgs(); csa.SortOption = csa.NumberOfCommentsDesc; try { CreateChannelsForTests(); IEnumerable<RentItServer.ITU.DatabaseWrapperObjects.Channel> channels = controller.GetChannels(csa); List<RentItServer.ITU.DatabaseWrapperObjects.Channel> theChannels = new List<RentItServer.ITU.DatabaseWrapperObjects.Channel>(channels); Assert.IsTrue(theChannels.Count >= interval); for (int i = 1; i < theChannels.Count; i++) { // The previous should be larger then current Assert.IsTrue(_dao.GetChannelComments(theChannels[i - 1].Id, 0, int.MaxValue).Count >= _dao.GetChannelComments(theChannels[i].Id, 0, int.MaxValue).Count); } } catch { Assert.Fail("An exception was raised"); } }
public void Controller_UpdateUser_State_EverythingUpdated() { controller = Controller.GetInstance(); RentItServer.ITU.DatabaseWrapperObjects.User user = TestExtensions._testUser1; try { string newName = "newtestname"; string newPw = "thisisanewpassword"; string newEmail = "*****@*****.**"; controller.UpdateUser(user.Id, newName, newPw, newEmail); User updatedUser = _dao.GetUser(user.Id); Assert.IsTrue(updatedUser.Username.Equals(newName)); Assert.IsTrue(updatedUser.Email.Equals(newEmail)); Assert.IsTrue(updatedUser.Password.Equals(newPw)); } catch (Exception e) { Assert.Fail("An exception was thrown. " + e); } }
public void Controller_SignUp_State_ProperAttributes() { controller = Controller.GetInstance(); RentItServer.ITU.DatabaseWrapperObjects.User user = controller.SignUp(testNameSignup, testEmailSignup, testPasswordSignup); testId = user.Id; Assert.IsNotNull(user); Assert.AreEqual(testNameSignup, user.Username); Assert.AreEqual(testEmailSignup, user.Email); }
public void Controller_GetChannelsWithFilter_Parameter_Null() { controller = Controller.GetInstance(); try { controller.GetChannels(null); Assert.Fail("No exception was raised"); } catch (ArgumentNullException) { //This is expected } }
public void Controller_SignUp_Parameter_ValidValidEmpty() { controller = Controller.GetInstance(); try { RentItServer.ITU.DatabaseWrapperObjects.User user = controller.SignUp(testname, testmail, ""); Assert.Fail("No exception was raised"); } catch (ArgumentException) { //this is good } }
public void Controller_SignUp_Parameter_ValidValidValid() { controller = Controller.GetInstance(); try { RentItServer.ITU.DatabaseWrapperObjects.User user = controller.SignUp(testNameSignup, testEmailSignup, testPasswordSignup); } catch (Exception e) { Assert.Fail("An exception was thrown " + e); } }
public void Controller_SignUp_Parameter_NullNullNull() { controller = Controller.GetInstance(); try { RentItServer.ITU.DatabaseWrapperObjects.User user = controller.SignUp(null, null, null); Assert.Fail("No exception was raised"); } catch (ArgumentNullException) { //this is good } }
public void Controller_Login_Parameter_ValidValid2() { controller = Controller.GetInstance(); try { RentItServer.ITU.DatabaseWrapperObjects.User user = controller.Login(testmail, testpw); } catch { Assert.Fail("An exception was raised"); } }
public void Controller_Login_Parameter_ValidEmpty2() { controller = Controller.GetInstance(); try { RentItServer.ITU.DatabaseWrapperObjects.User user = controller.Login(testmail, ""); Assert.Fail("No exception was raised"); } catch (ArgumentException) { //This is expected } }
public void Controller_DeleteUser_State_ProperCascading() { controller = Controller.GetInstance(); testId = TestExtensions._testUser1.Id; try { controller.DeleteUser(testId); User user = _dao.GetUser(testId); Assert.Fail("No exception was thrown. "); } catch { List<Channel> userCreatedChannels = _dao.GetCreatedChannels(testId); Assert.IsTrue(userCreatedChannels.Count == 0); List<Comment> userCreatedComments = _dao.GetUserComments(testId, 0, int.MaxValue); Assert.IsTrue(userCreatedComments.Count == 0); List<Vote> userVotes = _dao.GetUserVotes(testId); Assert.IsTrue(userVotes.Count == 0); testId = int.MaxValue; } }
public void Controller_UpdateUser_Parameter_PosNullNullNull() { controller = Controller.GetInstance(); RentItServer.ITU.DatabaseWrapperObjects.User user = TestExtensions._testUser1; try { controller.UpdateUser(user.Id, null, null, null); } catch (ArgumentNullException e) { Assert.Fail("An exception was thrown. " + e); } }
public void Controller_GetChannelsWithFilter_Parameter_Default() { controller = Controller.GetInstance(); ChannelSearchArgs csa = controller.GetDefaultChannelSearchArgs(); try { controller.GetChannels(csa); } catch { Assert.Fail("An exception was raised"); } }
public void Controller_UpdateUser_Parameter_PosNullNullValid() { controller = Controller.GetInstance(); RentItServer.ITU.DatabaseWrapperObjects.User user = TestExtensions._testUser1; testId = user.Id; try { controller.UpdateUser(testId, null, null, testpw); Assert.Fail("No exception was thrown"); } catch (ArgumentException) { //This is expected } }
public void Controller_GetChannelsWithFilter_State_SortHitsAscending() { controller = Controller.GetInstance(); ChannelSearchArgs csa = controller.GetDefaultChannelSearchArgs(); csa.SortOption = csa.HitsAsc; try { CreateChannelsForTests(); IEnumerable<RentItServer.ITU.DatabaseWrapperObjects.Channel> channels = controller.GetChannels(csa); List<RentItServer.ITU.DatabaseWrapperObjects.Channel> theChannels = new List<RentItServer.ITU.DatabaseWrapperObjects.Channel>(channels); Assert.IsTrue(theChannels.Count >= interval); for (int i = 1; i < theChannels.Count; i++) { // The previous should be less then current Assert.IsTrue(theChannels[i - 1].Hits <= theChannels[i].Hits); } } catch (Exception e) { Assert.Fail("An exception was raised. " + e); } }
/// <summary> /// Accessor method to access the only instance of the class /// </summary> /// <returns>The singleton instance of the class</returns> public static Controller GetInstance() { return _instance ?? (_instance = new Controller()); }