Esempio n. 1
0
        public void GetById_NotFound()
        {
            var controller = new ToggleController(_repositoryMock.Object);

            var result       = controller.Get(new Guid());
            var actionResult = result as NotFoundResult;

            Assert.IsNotNull(actionResult);
            Assert.AreEqual((int)HttpStatusCode.NotFound, actionResult.StatusCode);
        }
Esempio n. 2
0
        public void GetAll_Ok()
        {
            _repositoryMock.Setup(rep => rep.GetAll()).Returns(new List <Toggle>());
            var controller = new ToggleController(_repositoryMock.Object);

            var result       = controller.Get(null);
            var actionResult = result as OkObjectResult;
            var model        = actionResult?.Value as IEnumerable <ToggleDtoOutput>;

            Assert.IsNotNull(actionResult);
            Assert.IsNotNull(model);
            _repositoryMock.Verify(rep => rep.GetAll(), Times.Once);
            Assert.AreEqual((int)HttpStatusCode.OK, actionResult.StatusCode);
        }
Esempio n. 3
0
        public void GetById_Ok()
        {
            var id     = new Guid();
            var toggle = new Toggle
            {
                Id   = id,
                Name = "test"
            };

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

            var result       = controller.Get(id);
            var actionResult = result as OkObjectResult;
            var model        = actionResult?.Value as ToggleDtoOutput;

            Assert.IsNotNull(actionResult);
            Assert.IsNotNull(model);
            Assert.AreEqual((int)HttpStatusCode.OK, actionResult.StatusCode);
        }