コード例 #1
0
        public void DeleteGeocacheThatDoesNotExistAndExpectNotFound()
        {
            controller = new GeocacheApiController();
            var response = controller.Delete(20);

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(NotFoundResult));
        }
コード例 #2
0
        public void DeleteGeocacheThatDoesExistAndExpectOk()
        {
            controller = new GeocacheApiController();
            var response = controller.Delete(15);
            var contentResult = response as OkNegotiatedContentResult<Geocache>;

            Assert.IsNotNull(response);
            Assert.IsNotInstanceOfType(response, typeof(OkResult));
        }
コード例 #3
0
        public void Get()
        {
            controller = new GeocacheApiController();
            var response = controller.Get();
            var contentResult = response as OkNegotiatedContentResult<List<Geocache>>;

            Assert.IsInstanceOfType(response, typeof(OkResult));
            Assert.IsNotNull(response);
            Assert.IsNotNull(contentResult.Content);
        }
コード例 #4
0
        public void GetGeocacheById()
        {
            controller = new GeocacheApiController();
            var response = controller.Get(2);
            var contentResult = response as OkNegotiatedContentResult<Geocache>;
            Geocache geocache = contentResult.Content;

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkNegotiatedContentResult<Geocache>));
            Assert.IsNotNull(contentResult);
            Assert.AreEqual("BarCache", geocache.Name);
            Assert.AreEqual(47.256219M, geocache.Latitude);
            Assert.AreEqual(-122.439684M, geocache.Longitude);
        }
コード例 #5
0
        public void GetAllGeocaches()
        {
            controller = new GeocacheApiController();

            var response = controller.Get();
            var contentResult = response as OkNegotiatedContentResult<List<Geocache>>;

            List<Geocache> list = contentResult.Content;
            int count = list.Count;
            Geocache cache = list[0];

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkResult));
            Assert.AreEqual(12, count);
            Assert.IsNotNull(response);
            Assert.AreEqual("RustonWay", cache.Name);
        }
コード例 #6
0
        public void PostGeocache()
        {
            controller = new GeocacheApiController();
            Geocache geocache = new Geocache() { Name = "RustonWay2", Latitude = 47.238302M, Longitude = -122.491245M };
            var response = controller.Post(geocache);
            var contentResult = response as OkNegotiatedContentResult<Geocache>;

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkNegotiatedContentResult<Geocache>));
            Assert.IsNotNull(contentResult);
            Assert.AreEqual("RustonWay2", geocache.Name);
            Assert.AreEqual(47.238302M, geocache.Latitude);
            Assert.AreEqual(-122.491245M, geocache.Longitude);
        }
コード例 #7
0
        public void PutNewGeocache()
        {
            controller = new GeocacheApiController();
            Geocache geocache = new Geocache() { ID = 13, Name = "RustonWay3", Latitude = 47.258302M, Longitude = -122.401245M };
            var response = controller.Put(geocache.ID, geocache);
            var contentResult = response as OkNegotiatedContentResult<Geocache>;

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(StatusCodeResult));
        }