Esempio n. 1
0
        public void TestFullUpdateInvalidHomie()
        {
            var newHomie = HomiesTestHelpers.CreateHomie();

            _controller.ModelState.AddModelError("Email", "Required");

            var result = _controller.FullUpdate(newHomie);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult));
        }
Esempio n. 2
0
        public void TestFullUpdateValidHomie()
        {
            var newHomie = HomiesTestHelpers.CreateHomie();

            _mockHomieRepo
            .Setup(x => x.Edit(It.IsAny <Homie>()))
            .Verifiable();

            var result = _controller.FullUpdate(newHomie);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(NoContentResult));
            _mockHomieRepo.Verify();
        }
        public void TestGetByIdCorrectId()
        {
            var homie = HomiesTestHelpers.CreateHomie();

            _mockHomieRepo
            .Setup(x => x.GetById(It.IsAny <int>(), It.IsAny <Expression <Func <Homie, object> >[]>()))
            .Returns(homie)
            .Verifiable();

            var result = _controller.GetById(1);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(ActionResult <Homie>));
            _mockHomieRepo.Verify();
        }
Esempio n. 4
0
        public void TestCreateValidHomie()
        {
            var homie = HomiesTestHelpers.CreateHomie(3);

            _mockHomieRepo
            .Setup(x => x.Add(It.IsAny <Homie>()))
            .Verifiable();

            var result = _controller.Create(homie);

            Assert.IsNotNull(result);

            // the result should be a CreatedAtRouteResult
            Assert.IsInstanceOfType(result, typeof(CreatedAtRouteResult));
            _mockHomieRepo.Verify();
        }
Esempio n. 5
0
        public void TestCheckOutValidId()
        {
            var homie = HomiesTestHelpers.CreateHomie();

            _mockHomieRepo
            .Setup(x => x.GetById(It.IsAny <int>(), It.IsAny <Expression <Func <Homie, object> >[]>()))
            .Returns(homie)
            .Verifiable();
            _mockHomieRepo
            .Setup(x => x.CheckOut(It.IsAny <Homie>(), It.IsAny <DateTime>()))
            .Verifiable();

            var result = _controller.CheckOut(1);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(NoContentResult));
            _mockHomieRepo.Verify();
        }