public async Task SlettBestillingIkkeFunnet() { mockRepo.Setup(k => k.Slett(It.IsAny <int>())).ReturnsAsync(false); var bestillingController = new BestillingController(mockRepo.Object, mockLog.Object); mockSession[_loggetInn] = _loggetInn; mockHttpContext.Setup(s => s.Session).Returns(mockSession); bestillingController.ControllerContext.HttpContext = mockHttpContext.Object; var resultat = await bestillingController.Slett(It.IsAny <int>()) as NotFoundObjectResult; Assert.Equal((int)HttpStatusCode.NotFound, resultat.StatusCode); Assert.Equal("Kunne ikke slette bestillingen", resultat.Value); }
public async Task SlettBestillingIkkeloggetInn() { mockRepo.Setup(k => k.Slett(1)).ReturnsAsync(true); var bestillingController = new BestillingController(mockRepo.Object, mockLog.Object); mockSession[_loggetInn] = _ikkeLoggetInn; mockHttpContext.Setup(s => s.Session).Returns(mockSession); bestillingController.ControllerContext.HttpContext = mockHttpContext.Object; var resultat = await bestillingController.Slett(1) as UnauthorizedObjectResult; Assert.Equal((int)HttpStatusCode.Unauthorized, resultat.StatusCode); Assert.Equal("ikke logget inn", resultat.Value); }
public async Task SlettBestillingLoggetInn() { mockRepo.Setup(k => k.Slett(It.IsAny <int>())).ReturnsAsync(true); var bestillingController = new BestillingController(mockRepo.Object, mockLog.Object); mockSession[_loggetInn] = _loggetInn; mockHttpContext.Setup(s => s.Session).Returns(mockSession); bestillingController.ControllerContext.HttpContext = mockHttpContext.Object; var resultat = await bestillingController.Slett(It.IsAny <int>()) as OkObjectResult; Assert.Equal((int)HttpStatusCode.OK, resultat.StatusCode); Assert.Equal("Bestillingen ble slettet", resultat.Value); }