Example #1
0
        public async Task Put_WhenCalled_ReturnsOkResult()
        {
            var mockedRepo  = new Mock <IHomeRepository>();
            var environment = new Environment()
            {
                Id = Guid.Parse("00000000-0000-0000-0000-000000000000")
            };

            mockedRepo.Setup(repo => repo.EditEnvironment(environment)).ReturnsAsync(true);
            var controller = new EnvironmentsController(mockedRepo.Object);
            var result     = await controller.Put(environment);

            var contentResult = (result as OkObjectResult).Value;

            Assert.NotNull(contentResult);
            Assert.Equal(contentResult, environment);
        }
Example #2
0
        public async Task Put_WhenCalled_BadObject_ReturnsBadRequest()
        {
            var mockedRepo = new Mock <IHomeRepository>();

            var controller = new EnvironmentsController(mockedRepo.Object);

            var newEnv = new Environment()
            {
                Id = Guid.Parse("00000000-0000-0000-0000-000000000003")
            };

            mockedRepo.Setup(repo => repo.EditEnvironment(newEnv)).ReturnsAsync(false);

            var result = await controller.Put(newEnv);

            var contentResult = result as BadRequestResult;

            Assert.NotNull(contentResult);
        }