コード例 #1
0
 public void ChangeProfileTest()
 {
     UsersController target = new UsersController(userRepository);
     User user = userRepository.CreateUser("Test", "Test", "*****@*****.**");
     target = (UsersController)TestHelper.CreateControllerForUser(user, target);
     HttpPostedFileBase image = null;
     ActionResult actual;
     actual = target.ChangeProfile(user, image);
     Assert.IsNotNull(actual);
     Assert.IsTrue(actual is RedirectToRouteResult);
     userRepository.DeleteUser(user);
 }
コード例 #2
0
 public void AddSubscriptionTest()
 {
     var userlogin = userRepository.CreateUser("Test", "Test");
     var testUser = userRepository.CreateUser("Test2", "Test");
     UsersController target = new UsersController(userRepository);
     target = (UsersController)TestHelper.CreateControllerForUser(userlogin, target);
     int whomUserId = testUser.Id;
     var actual = target.AddSubscription(whomUserId);
     Assert.IsNotNull(actual);
     Assert.IsTrue(actual is EmptyResult);
     userRepository.DeleteUser(userlogin);
     userRepository.DeleteUser(testUser);
 }
コード例 #3
0
 public void ChangeProfileTest1()
 {
     UsersController target = new UsersController(userRepository);
     User user = userRepository.CreateUser("Test", "Test");
     target = (UsersController)TestHelper.CreateControllerForUser(user, target);
     ActionResult actual;
     actual = target.ChangeProfile();
     Assert.IsNotNull(actual);
     Assert.IsTrue(actual is ViewResult);
     userRepository.DeleteUser(user);
 }
コード例 #4
0
 public void UnsubscribeTest()
 {
     UsersController target = new UsersController(userRepository);
     User whoUser = userRepository.CreateUser("Test","Test");
     target = (UsersController)TestHelper.CreateControllerForUser(whoUser, target);
     User whomUser = userRepository.CreateUser("Test1", "Test");
     userRepository.AddSubscription(whoUser, whomUser);
     ActionResult actual;
     actual = target.Unsubscribe(whomUser.Id);
     Assert.IsNotNull(actual);
     Assert.IsTrue(actual is EmptyResult);
     Assert.AreEqual(userRepository.GetCountReadUsers(whoUser.Id), 0);
     userRepository.DeleteUser(whoUser);
     userRepository.DeleteUser(whomUser);
 }
コード例 #5
0
 public void GetUserMinDetailByIdTest()
 {
     UsersController target = new UsersController(userRepository);
     User user = userRepository.CreateUser("Test", "Test");
     ActionResult actual;
     actual = target.GetUserMinDetailById(user.Id);
     Assert.IsNotNull(actual);
     Assert.IsTrue(actual is PartialViewResult);
     userRepository.DeleteUser(user);
 }
コード例 #6
0
 public void GetImageTest()
 {
     var img = Properties.Resources.Image1;
     var stream = new MemoryStream();
     img.Save(stream, ImageFormat.Jpeg);
     byte[] photo = stream.ToArray();
     UsersController target = new UsersController(userRepository);
     User user = userRepository.CreateUser("Test", "Test");
     userRepository.AddOrUpdatePhoto(user.Id, photo);
     ActionResult actual;
     actual = target.GetImage(user.Id);
     Assert.IsNotNull(actual);
     Assert.IsTrue(actual is FileResult);
     userRepository.DeleteUser(user);
 }