Example #1
0
        public void RemoveIgnoreInvalid()
        {
            // Arrange
            Mock <User>        userMock    = new Mock <User>();
            Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object);

            managerMock.Expect(m => m.GetUser(3))
            .Returns <User>(null)
            .Verifiable();
            BuddyListController controller = new BuddyListController(managerMock.Object);

            // Act
            ActionResult result = controller.RemoveIgnore(3);

            // Assert
            Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view");
            Assert.That(controller.ModelState.IsValid, Is.False, "Errors should be returned");
            managerMock.Verify();
        }
Example #2
0
        public void RemoveIgnore()
        {
            // Arrange
            Mock <User> ignoreUserMock = new Mock <User>();
            Mock <User> userMock       = new Mock <User>();

            userMock.Expect(u => u.RemoveIgnore(ignoreUserMock.Object))
            .Verifiable();
            Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object);

            managerMock.Expect(m => m.GetUser(1))
            .Returns(ignoreUserMock.Object)
            .Verifiable();
            BuddyListController controller = new BuddyListController(managerMock.Object);

            // Act
            ActionResult result = controller.RemoveIgnore(1);

            // Assert
            Assert.That(result, Is.TypeOf(typeof(RedirectToRouteResult)), "Should return a redirect");
            Assert.That(controller.ModelState.IsValid, "No errors should be returned");
            managerMock.Verify();
        }
Example #3
0
        public void RemoveIgnoreNotInList()
        {
            // Arrange
            Mock <User> ignoreUserMock = new Mock <User>();
            Mock <User> userMock       = new Mock <User>();

            userMock.Expect(u => u.RemoveIgnore(ignoreUserMock.Object))
            .Throws(new ArgumentException())
            .Verifiable();
            Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object);

            managerMock.Expect(m => m.GetUser(2))
            .Returns(ignoreUserMock.Object)
            .Verifiable();
            BuddyListController controller = new BuddyListController(managerMock.Object);

            // Act
            ActionResult result = controller.RemoveIgnore(2);

            // Assert
            Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view");
            Assert.That(controller.ModelState.IsValid, Is.False, "Errors should be returned");
            managerMock.Verify();
        }