Ejemplo n.º 1
0
        public void UpdatePoint_200()
        {
            newUser = _tu.CreateUserObject();
            Session newSession = _tu.CreateSessionObject(newUser);

            _tu.CreateSessionInDb(newSession);

            var point = _tu.CreatePointObject(179, 81);

            point = _tu.CreatePointInDb(point);

            var endpoint = API_ROUTE_LOCAL + "/api/point/" + point.Id;

            controller.Request = new HttpRequestMessage
            {
                RequestUri = new Uri(endpoint)
            };

            var request = new HttpRequestMessage();

            request.Headers.Add("token", newSession.Token);

            controller.Request = request;

            OkNegotiatedContentResult <Point> response = (OkNegotiatedContentResult <Point>)controller.Get(point.Id.ToString());

            var pointPost = new PointUpdateDTO
            {
                Longitude   = response.Content.Longitude,
                Latitude    = response.Content.Latitude,
                Description = "updatedDescription",
                Name        = "updatedName",
                Id          = response.Content.Id
            };

            Assert.AreEqual(point.Name, response.Content.Name);
            Assert.AreEqual(point.Description, response.Content.Description);
            Assert.AreEqual(point.Longitude, response.Content.Longitude);
            Assert.AreEqual(point.Latitude, response.Content.Latitude);

            OkNegotiatedContentResult <Point> result = (OkNegotiatedContentResult <Point>)controller.Put(pointPost);

            Assert.AreEqual(pointPost.Name, result.Content.Name);
            Assert.AreEqual(pointPost.Description, result.Content.Description);
            Assert.AreEqual(pointPost.Longitude, result.Content.Longitude);
            Assert.AreEqual(pointPost.Latitude, result.Content.Latitude);
            Assert.AreEqual(response.Content.CreatedAt, result.Content.CreatedAt);
            Assert.AreNotEqual(response.Content.UpdatedAt, result.Content.UpdatedAt);
        }