public void Put()
        {
            // Arrange
            DeviseController controller = new DeviseController();
            Devise           dFalse     = new Devise(7, "test", 2);
            Devise           dUpdated   = new Devise(1, "testYes", 2);

            // Act
            IHttpActionResult result1 = controller.Put(1, dUpdated);
            var result = controller.Put(1, dUpdated);
            IHttpActionResult result2 = controller.Put(2, dFalse);
            IHttpActionResult result3 = controller.Put(7, dFalse);


            // Assert
            Assert.AreEqual(1, dUpdated.Id);
            Assert.AreEqual(dUpdated, controller.Get().ElementAt(0));
            Assert.IsInstanceOfType(result1, typeof(StatusCodeResult));
            Assert.IsInstanceOfType(result2, typeof(BadRequestResult)); // devise.id is not the same as the id parameter
            Assert.IsInstanceOfType(result3, typeof(NotFoundResult));   // Id is not found


            controller.ModelState.AddModelError("Error", "Error");
            var response = controller.Put(7, dFalse);

            Assert.IsInstanceOfType(response, typeof(InvalidModelStateResult));
        }
        public void Get(int id)
        {
            // Arrange
            DeviseController controller = new DeviseController();

            // Act
            var result = controller.Get(1) as OkNegotiatedContentResult <Devise>;
            IHttpActionResult result1 = controller.Get(1);
            IHttpActionResult result2 = controller.Get(15);

            // Assert
            Assert.IsInstanceOfType(result2, typeof(NotFoundResult));
            Assert.IsNotNull(result1);
            Assert.IsInstanceOfType(result1, typeof(OkNegotiatedContentResult <Devise>));
            Assert.AreEqual(new Devise(1, "Dollar", 1.08), result.Content);
        }
        public void GetTest()
        {
            DeviseController dc = new DeviseController();

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

            Assert.AreEqual(devises.Count(), 3);
        }
        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);
        }
        public void Get()
        {
            // Arrange
            DeviseController controller = new DeviseController();

            // Act
            IEnumerable <Devise> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count());
            Assert.AreEqual(new Devise(1, "Dollar", 1.08), result.ElementAt(0));
            Assert.AreEqual(new Devise(2, "Franc Suisse", 1.07), result.ElementAt(1));
            Assert.AreEqual(new Devise(3, "Yen", 120), result.ElementAt(2));
        }
        public void PutTest()
        {
            DeviseController     dc      = new DeviseController();
            IEnumerable <Devise> devises = dc.Get();

            Devise toEdit = devises.FirstOrDefault();

            Assert.IsNotNull(toEdit);

            toEdit.Nom = "Donatien";


            var result = dc.Put(1, toEdit) as StatusCodeResult;

            Assert.AreEqual(result.StatusCode, HttpStatusCode.OK);
        }
        public void DeleteTest()
        {
            DeviseController dc = new DeviseController();
            OkNegotiatedContentResult <Devise> toDelete = (OkNegotiatedContentResult <Devise>)dc.Get(2);

            OkNegotiatedContentResult <Devise> result = (OkNegotiatedContentResult <Devise>)dc.Delete(2);

            Assert.AreEqual(result.Content, toDelete.Content);
        }
        public void GetTest1()
        {
            DeviseController dc = new DeviseController();

            OkNegotiatedContentResult <Devise> result = (OkNegotiatedContentResult <Devise>)dc.Get(2);

            Assert.AreEqual(result.Content.Id, 2);
        }