コード例 #1
0
        public async Task SletteTurIkkeLoggetInn()
        {
            mockRep.Setup(k => k.SlettTur(It.IsAny <int>())).ReturnsAsync(true);

            var bestillingController = new BestillingController(mockRep.Object, mockLog.Object);

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

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

            // Assert
            Assert.Equal((int)HttpStatusCode.Unauthorized, resultat.StatusCode);
            Assert.Equal("Ikke logget inn", resultat.Value);
        }
コード例 #2
0
        public async Task SlettTurLoggetInnIkkeOK()
        {
            // Arrange

            mockRep.Setup(k => k.SlettTur(It.IsAny <int>())).ReturnsAsync(false);

            var bestillingController = new BestillingController(mockRep.Object, mockLog.Object);

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

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

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