Exemplo n.º 1
0
        public void OrderByTest()
        {
            // Arrange
            CmpdEntities context = new CmpdEntities();
            List <GetOfficerShootings_Result> db = context.GetOfficerShootings();

            OfficerShootingsController controller = new OfficerShootingsController(context)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            // Act
            var AscResponse = controller.OrderBy("date", "ascending")
                              as OkNegotiatedContentResult <List <GetOfficerShootings_Result> >;

            var DescResponse = controller.OrderBy("date", "descending")
                               as OkNegotiatedContentResult <List <GetOfficerShootings_Result> >;

            DateTime ascFirst  = DateTime.Parse(AscResponse.Content.First().YEAR_MONTH);
            DateTime ascLast   = DateTime.Parse(AscResponse.Content.Last().YEAR_MONTH);
            DateTime descFirst = DateTime.Parse(DescResponse.Content.First().YEAR_MONTH);
            DateTime descLast  = DateTime.Parse(DescResponse.Content.Last().YEAR_MONTH);

            // Assert
            Assert.IsTrue(ascFirst < ascLast);
            Assert.IsTrue(descFirst > descLast);
        }
Exemplo n.º 2
0
        public void GetOfficerShootingsTest()
        {
            // Arrange
            CmpdEntities context = GetOfficerShootings();
            OfficerShootingsController controller = new OfficerShootingsController(context)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            // Act
            var response = controller.GetOfficerShootings()
                           as OkNegotiatedContentResult <List <GetOfficerShootings_Result> >;

            var shooting = response.Content.First();

            // Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(shooting);
        }
Exemplo n.º 3
0
        public void GetOfficerShootingsTest1()
        {
            // Arrange
            String       startDate = "1/1/2016";
            String       endDate   = "12/31/2016";
            CmpdEntities context   = new CmpdEntities();
            List <GetOfficerShootings_Result> db = context.GetOfficerShootings();

            OfficerShootingsController controller = new OfficerShootingsController(context)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };


            // Act
            var response = controller.GetOfficerShootings(startDate, endDate)
                           as OkNegotiatedContentResult <List <GetOfficerShootings_Result> >;

            // Assert
            Assert.IsNotNull(response);
            Assert.IsFalse(response.Content.Exists(s => s.YR != 2016));
        }
Exemplo n.º 4
0
        public void GetOfficerShootingsById()
        {
            // Arrange
            int          id      = 7307;
            CmpdEntities context = GetOfficerShootings();
            List <GetOfficerShootings_Result> db = context.GetOfficerShootings();

            OfficerShootingsController controller = new OfficerShootingsController(context)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            // Act
            var response = controller.GetOfficerShootings(id)
                           as OkNegotiatedContentResult <GetOfficerShootings_Result>;

            var shooting = db.Find(s => s.INCIDENT_ID == id);

            // Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(shooting.INCIDENT_ID, response.Content.INCIDENT_ID);
        }