Example #1
0
        public void Put_InvalidId_BadRequest()
        {
            var controller = new ToggleController(_repositoryMock.Object);

            var result       = controller.Put(new Guid(), new ToggleDtoInput());
            var objectResult = result as BadRequestResult;

            Assert.IsNotNull(objectResult);
            Assert.AreEqual((int)HttpStatusCode.BadRequest, objectResult.StatusCode);
        }
Example #2
0
        public void Put_Successful()
        {
            var id     = new Guid();
            var toggle = new Toggle
            {
                Id   = id,
                Name = "test"
            };

            _repositoryMock.Setup(rep => rep.Get(id)).Returns(toggle);
            var toggleInput = new ToggleDtoInput();
            var controller  = new ToggleController(_repositoryMock.Object);

            var result       = controller.Put(id, toggleInput);
            var actionResult = result as NoContentResult;

            Assert.IsNotNull(actionResult);
            _repositoryMock.Verify(rep => rep.Save(), Times.Once);
            Assert.AreEqual((int)HttpStatusCode.NoContent, actionResult.StatusCode);
        }