public void Post()
        {
            // Arrange
            DeviseController controller = new DeviseController();
            Devise           d          = new Devise();

            // Act
            var result = controller.Post(d) as CreatedAtRouteNegotiatedContentResult <Devise>;
            IHttpActionResult result1 = controller.Post(new Devise());

            // Assert
            Assert.IsInstanceOfType(result1, typeof(CreatedAtRouteNegotiatedContentResult <Devise>));
            Assert.AreEqual(d, result.Content);

            controller.ModelState.AddModelError("Error", "Error");
            var response = controller.Post(d);

            Assert.IsInstanceOfType(response, typeof(InvalidModelStateResult));
        }
Beispiel #2
0
        public async Task Post_WellFormedObjectPassed()
        {
            // Act
            var result = await _controller.Post(new Devise(4, "Euro", 1.15)) as CreatedAtRouteResult;

            List <Devise> list = (await _controller.GetAll()).ToList();

            // Assert
            Assert.IsInstanceOfType(result, typeof(CreatedAtRouteResult), "Pas un CreatedAtRouteResult");
            Assert.IsTrue(list.Contains((Devise)result.Value));
        }
        public void PostTest()
        {
            DeviseController dc = new DeviseController();

            Devise toAdd = new Devise(4, "Test", 12000);

            dc.Post(toAdd);

            IEnumerable <Devise> devises2 = dc.Get();

            Assert.AreEqual(devises2.Count(), 4);
        }