コード例 #1
0
ファイル: AvgangTest.cs プロジェクト: MagnusHJK/WebApp-Oppg1
        public async Task SlettAvgangIkkeInnlogget()
        {
            mockRep.Setup(s => s.SlettAvgang(It.IsAny <int>())).ReturnsAsync(false);

            var avgangController = new AvgangController(mockRep.Object, mockLog.Object);

            mockSession[_loggetInn] = _ikkeLoggetInn;
            mockHttpContext.Setup(s => s.Session).Returns(mockSession);
            avgangController.ControllerContext.HttpContext = mockHttpContext.Object;

            //Act
            var resultat = await avgangController.SlettAvgang(It.IsAny <int>()) as UnauthorizedObjectResult;

            //Assert
            Assert.Equal((int)HttpStatusCode.Unauthorized, resultat.StatusCode);
            Assert.Equal("Ikke innlogget", resultat.Value);
        }
コード例 #2
0
ファイル: AvgangTest.cs プロジェクト: MagnusHJK/WebApp-Oppg1
        public async Task SlettAvgangInnloggetIkkeOK()
        {
            mockRep.Setup(s => s.SlettAvgang(It.IsAny <int>())).ReturnsAsync(false);

            var avgangController = new AvgangController(mockRep.Object, mockLog.Object);

            mockSession[_loggetInn] = _loggetInn;
            mockHttpContext.Setup(s => s.Session).Returns(mockSession);
            avgangController.ControllerContext.HttpContext = mockHttpContext.Object;

            //Act
            var resultat = await avgangController.SlettAvgang(It.IsAny <int>()) as BadRequestObjectResult;

            //Assert
            Assert.Equal((int)HttpStatusCode.BadRequest, resultat.StatusCode);
            Assert.Equal("Avgangen ble ikke slettet", resultat.Value);
        }