Beispiel #1
0
        public async Task LagAvgangIkkeInnlogget()
        {
            DateTime dato = new DateTime(2020, 10, 10);

            mockRep.Setup(s => s.LagAvgang(It.IsAny <int>(), It.IsAny <int>(), dato.ToString(), It.IsAny <int>())).ReturnsAsync(true);

            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.LagAvgang(It.IsAny <int>(), It.IsAny <int>(), dato.ToString(), It.IsAny <int>()) as UnauthorizedObjectResult;

            //Assert
            Assert.Equal((int)HttpStatusCode.Unauthorized, resultat.StatusCode);
            Assert.Equal("Ikke innlogget", resultat.Value);
        }
Beispiel #2
0
        public async Task LagAvgangInnloggetIkkeOK()
        {
            DateTime dato = new DateTime(2020, 10, 10);

            mockRep.Setup(s => s.LagAvgang(It.IsAny <int>(), It.IsAny <int>(), dato.ToString(), 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.LagAvgang(It.IsAny <int>(), It.IsAny <int>(), dato.ToString(), It.IsAny <int>()) as BadRequestObjectResult;

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