Esempio n. 1
0
        [InlineData("453a2901-150b-4211-84b1-a40ac2ba4a35", 15, -1, false)] // Unsuccessful Kick (no such group)
        public void TestKickFromGroup(string creatorAspId, int targetUserId, int groupId, bool expectingSuccess)
        {
            var controllerContextMock = new Mock <ControllerContext>()
            {
                CallBase = true
            };
            var contextMock = new Mock <ApplicationDbContext>()
            {
                CallBase = true
            };

            contextMock.Setup(c => c.SaveChanges()).Returns(1);
            var controller = new GroupsController
            {
                ControllerContext = controllerContextMock.Object,
                Context           = contextMock.Object,
                GetUserId         = () => creatorAspId
            };

            var result = controller.Kick(targetUserId, groupId);

            if (expectingSuccess)
            {
                Assert.True(result is RedirectToRouteResult);
                var redirectResult = (RedirectToRouteResult)result;
                Assert.Equal("Details", redirectResult.RouteValues["action"]);
            }
            else
            {
                Assert.True(result is HttpNotFoundResult);
            }
        }