public void Create_WhenCalled_ReturnsCorrectActionAndView()
        {
            // Arrange

            // Act
            ViewResult result = _controller.Create() as ViewResult;

            // Assert
            Assert.AreEqual("Create", result.ViewBag.Action);
            Assert.AreEqual("Edit", result.ViewName);
        }
Esempio n. 2
0
        public void Create_BadWeather()
        {
            // #1 - Try creating an experiment with empty/null body
            var res = _controller.Create(null) as BadRequestErrorMessageResult;

            Assert.NotNull(res);
            Assert.AreEqual("Empty request body!", res.Message);

            // #2 - Try creating an experiment without providing an experiment name
            _controller.ModelState.AddModelError("error", "An experiment name must be provided!");
            var experimentRequest = new ExperimentRequest()
            {
                Description = "The most crazy experiment you can find out there"
            };

            res = _controller.Create(experimentRequest) as BadRequestErrorMessageResult;
            Assert.NotNull(res);
            Assert.AreEqual("An experiment name must be provided!", res.Message);
        }