usingMicrosoft.VisualStudio.TestTools.UnitTesting;usingPollutometerWebApi.Models;usingSystem;namespacePollutometerWebApi.Tests{[TestClass()]publicclassSqlOperatorTests{[TestMethod()]publicvoidGetReadingsTest(){varreadings=SqlOperator.GetReadings("SELECT * FROM Readings");Assert.IsTrue(readings.Count>=1);}[TestMethod()]publicvoidPostReadingTest(){varnewReading=newReading{TimeStamp=(int)DateTimeOffset.Now.ToUnixTimeSeconds(),Co=0.0,No=0.0,So=0.0};SqlOperator.PostReading(newReading);varcommand="SELECT * FROM Readings "+"WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)";varlatestReading=SqlOperator.GetReadings(command)[0];varcommand2=$"SELECT * FROM Readings WHERE Id={latestReading.Id}";varreading=SqlOperator.GetReadings(command2)[0];Assert.AreEqual(newReading.TimeStamp,reading.TimeStamp);}[TestMethod()]publicvoidPutReadingTest(){varnewReading=newReading{TimeStamp=(int)DateTimeOffset.Now.ToUnixTimeSeconds(),Co=0.5,No=0.5,So=0.5};varcommand="SELECT * FROM Readings "+"WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)";varlatestReading=SqlOperator.GetReadings(command)[0];SqlOperator.PutReading(latestReading.Id,newReading);varcommand2=$"SELECT * FROM Readings WHERE Id={latestReading.Id}";varreading=SqlOperator.GetReadings(command2)[0];Assert.AreEqual(newReading.TimeStamp,reading.TimeStamp);}[TestMethod()]publicvoidDeleteReadingTest(){varcommand="SELECT * FROM Readings "+"WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)";varlatestReading=SqlOperator.GetReadings(command)[0];SqlOperator.DeleteReading(latestReading.Id);varcommand2=$"SELECT * FROM Readings WHERE Id={latestReading.Id}";varreadings=SqlOperator.GetReadings(command2);Assert.IsTrue(readings.Count==0);}}}