Esempio n. 1
0
        [InlineData("e48d6b01-3dc8-4f11-a86c-c35affb09c0c", 19, false)] // Unsuccessful Close (User is not creator)
        public void TestCloseGroup(string creatorAspId, 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.Close(groupId);

            if (expectingSuccess)
            {
                Assert.True(result is RedirectToRouteResult);
            }
            else
            {
                Assert.True(result is HttpNotFoundResult);
            }
        }