Exemplo n.º 1
0
        public async Task HentAlleBestillingerIkkeOK()
        {
            mockRep.Setup(s => s.HentAlleBestillinger()).ReturnsAsync(() => null);
            var BestillingController = new BestillingController(mockRep.Object, mockLog.Object);

            var resultat = await BestillingController.HentAlleBestillinger() as NotFoundObjectResult;

            //Assert
            Assert.Equal((int)HttpStatusCode.NotFound, resultat.StatusCode);
            Assert.Equal("Ingen bestillinger funnet", resultat.Value);
        }
Exemplo n.º 2
0
        public async Task HentAlleBestillingerOK()
        {
            Bestillinger bestilling = new Bestillinger {
                Id = 1, Antall = 5, Avgang = It.IsAny <Avganger>(), Bruker = It.IsAny <Brukere>()
            };
            List <Bestillinger> bestillingListe = new List <Bestillinger> {
                bestilling
            };

            mockRep.Setup(s => s.HentAlleBestillinger()).ReturnsAsync(bestillingListe);
            var BestillingController = new BestillingController(mockRep.Object, mockLog.Object);

            var resultat = await BestillingController.HentAlleBestillinger() as OkObjectResult;

            //Assert
            Assert.Equal((int)HttpStatusCode.OK, resultat.StatusCode);
            Assert.Equal <List <Bestillinger> >((List <Bestillinger>)resultat.Value, bestillingListe);
        }