コード例 #1
0
        public void TestDelete()
        {
            // Arrange
            MeassurementsController mc = new MeassurementsController();

            // Act
            // Insert new M and then delete it, then check if it exists, then check if it doesn't exist
            Meassurement m = new Meassurement
            {
                Humidity = "20",
                Pressure = "21",
                Temperature = "22",
                TimeStamp = DateTime.Now
            };
            int newMId = mc.Post(m);

            Meassurement postedM = mc.Get(newMId);

            // Assert
            if (postedM != null)
            {
                // Delete returns id of the deleted.
                int delid = mc.Delete(postedM.Id);

                // Assert that the deleted id is the same as the id of the posted M
                Assert.AreEqual(postedM.Id, delid);
            }
            else
            {
                // Failed, did not post to db
                Assert.Fail();
            }
        }
コード例 #2
0
        public void TestPost()
        {
            // Arrange
            MeassurementsController mc = new MeassurementsController();

            // Act
            // Insert new M then get it and check if it exists
            Meassurement m = new Meassurement
            {
                Humidity = "20",
                Pressure = "21",
                Temperature = "22",
                TimeStamp = DateTime.Now
            };
            int newMId = mc.Post(m);

            Meassurement postedM = mc.Get(newMId);

            // Assert
            Assert.IsNotNull(postedM);
        }