From 08e7a82cc7b237e550c0236bebd4f41c3c3f4acf Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Fri, 16 Mar 2018 21:40:28 +0100 Subject: Moved API to separate folder. --- PollutometerWebApi.Tests/AqiCalculatorTests.cs | 51 --------- PollutometerWebApi.Tests/EmailSenderTests.cs | 21 ---- .../PollutometerWebApi.Tests.csproj | 125 --------------------- .../Properties/AssemblyInfo.cs | 36 ------ .../ReadingsControllerTests.cs | 116 ------------------- PollutometerWebApi.Tests/SqlOperatorTests.cs | 68 ----------- PollutometerWebApi.Tests/app.config | 11 -- PollutometerWebApi.Tests/packages.config | 10 -- 8 files changed, 438 deletions(-) delete mode 100644 PollutometerWebApi.Tests/AqiCalculatorTests.cs delete mode 100644 PollutometerWebApi.Tests/EmailSenderTests.cs delete mode 100644 PollutometerWebApi.Tests/PollutometerWebApi.Tests.csproj delete mode 100644 PollutometerWebApi.Tests/Properties/AssemblyInfo.cs delete mode 100644 PollutometerWebApi.Tests/ReadingsControllerTests.cs delete mode 100644 PollutometerWebApi.Tests/SqlOperatorTests.cs delete mode 100644 PollutometerWebApi.Tests/app.config delete mode 100644 PollutometerWebApi.Tests/packages.config (limited to 'PollutometerWebApi.Tests') diff --git a/PollutometerWebApi.Tests/AqiCalculatorTests.cs b/PollutometerWebApi.Tests/AqiCalculatorTests.cs deleted file mode 100644 index e84b687..0000000 --- a/PollutometerWebApi.Tests/AqiCalculatorTests.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using PollutometerWebApi.Models; - -namespace PollutometerWebApi.Tests -{ - [TestClass()] - public class AqiCalculatorTests - { - [TestMethod()] - public void CalculateAqiPerfectTest() - { - var reading = new Reading - { - Co = 2.2, - No = 0.1, - So = 0.8 - }; - - var result = AqiCalculator.CalculateAqi(reading); - Assert.AreEqual(398.0100502512563, result.Value); - } - - [TestMethod()] - public void CalculateAqiBigNumbersTest() - { - var reading = new Reading - { - Co = 100.2, - No = 100.1, - So = 100.8 - }; - - var result = AqiCalculator.CalculateAqi(reading); - Assert.AreEqual(0, result.Value); - } - - [TestMethod()] - public void CalculateAqiZerosTest() - { - var reading = new Reading - { - Co = 0, - No = 0, - So = 0 - }; - - var result = AqiCalculator.CalculateAqi(reading); - Assert.AreEqual(0, result.Value); - } - } -} \ No newline at end of file diff --git a/PollutometerWebApi.Tests/EmailSenderTests.cs b/PollutometerWebApi.Tests/EmailSenderTests.cs deleted file mode 100644 index 427ec92..0000000 --- a/PollutometerWebApi.Tests/EmailSenderTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using PollutometerWebApi.Models; - -namespace PollutometerWebApi.Tests -{ - [TestClass()] - public class EmailSenderTests - { - [TestMethod()] - public void SendEmailTest() - { - var aqi = new Aqi - { - GasName = "SO", - Value = 69, - Level = "Moderate" - }; - EmailSender.SendEmail(aqi); - } - } -} \ No newline at end of file diff --git a/PollutometerWebApi.Tests/PollutometerWebApi.Tests.csproj b/PollutometerWebApi.Tests/PollutometerWebApi.Tests.csproj deleted file mode 100644 index 6ff37aa..0000000 --- a/PollutometerWebApi.Tests/PollutometerWebApi.Tests.csproj +++ /dev/null @@ -1,125 +0,0 @@ - - - - - Debug - AnyCPU - {94A21C38-920E-42EF-8D48-B133D635EAFA} - Library - Properties - PollutometerWebApi.Tests - PollutometerWebApi.Tests - v4.6.2 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll - True - - - - - ..\packages\Microsoft.AspNet.WebApi.Client.5.2.0\lib\net45\System.Net.Http.Formatting.dll - - - - ..\packages\Microsoft.AspNet.WebApi.Core.5.2.0\lib\net45\System.Web.Http.dll - - - ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.0\lib\net45\System.Web.Http.WebHost.dll - - - - - - - - - - - - - - - - - - - - - - - - {22C32F4C-0DEB-40EA-9D56-48942CBB2A07} - PollutometerWebApi - - - - - - - False - - - False - - - False - - - False - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/PollutometerWebApi.Tests/Properties/AssemblyInfo.cs b/PollutometerWebApi.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index d6c3cc7..0000000 --- a/PollutometerWebApi.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PollutometerWebApi.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PollutometerWebApi.Tests")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("94a21c38-920e-42ef-8d48-b133d635eafa")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PollutometerWebApi.Tests/ReadingsControllerTests.cs b/PollutometerWebApi.Tests/ReadingsControllerTests.cs deleted file mode 100644 index 647649d..0000000 --- a/PollutometerWebApi.Tests/ReadingsControllerTests.cs +++ /dev/null @@ -1,116 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using PollutometerWebApi.Models; -using System; -using System.Collections.Generic; -using System.Web.Http.Results; - -namespace PollutometerWebApi.Controllers.Tests -{ - [TestClass()] - public class ReadingsControllerTests - { - ReadingsController controller = new ReadingsController(); - - [TestMethod()] - public void GetAllReadingsTest() - { - var actionResult = controller.GetAllReadings(); - var content = ((OkNegotiatedContentResult>)actionResult).Content; - Assert.IsTrue(content.Count >= 1); - } - - - [TestMethod()] - public void GetReadingTest() - { - var actionResult = controller.GetReading(0); - Assert.IsInstanceOfType(actionResult, typeof(OkNegotiatedContentResult)); - } - - [TestMethod()] - public void GetLatestReadingTest() - { - var actionResult = controller.GetLatestReading(); - var content = ((OkNegotiatedContentResult)actionResult).Content; - Assert.IsNotNull(content); - } - - [TestMethod()] - public void GetReadingsFromLastWeekTest() - { - var actionResult = controller.GetReadingsFromLastWeek(); - var content = ((OkNegotiatedContentResult>)actionResult).Content; - foreach(var reading in content) - { - var now = DateTimeOffset.Now.ToUnixTimeSeconds(); - Assert.IsTrue(reading.TimeStamp < now && reading.TimeStamp > now - 7*24*3600); - } - } - - [TestMethod()] - public void PostReadingPassTest() - { - var newReading = new Reading - { - TimeStamp = (int)DateTimeOffset.Now.ToUnixTimeSeconds(), - Co = 1.0, - No = 1.0, - So = 1.0 - }; - var actionResult = controller.PostReading(newReading); - var reading = controller.GetLatestReading(); - var content = ((OkNegotiatedContentResult)reading).Content; - Assert.AreEqual(newReading.TimeStamp, content.TimeStamp); - } - - [TestMethod()] - public void PostReadingFailTest() - { - var actionResult = controller.PostReading(null); - Assert.IsInstanceOfType(actionResult, typeof(BadRequestResult)); - } - - [TestMethod()] - public void PutReadingPassTest() - { - var latest = controller.GetLatestReading(); - var content = ((OkNegotiatedContentResult)latest).Content; - var actionResult = controller.PutReading(content.Id, - new Reading - { - TimeStamp = (int)DateTimeOffset.Now.ToUnixTimeSeconds(), - Co = 2.0, - No = 2.0, - So = 2.0 - } - ); - Assert.AreEqual(typeof(OkResult), actionResult.GetType()); - } - - [TestMethod()] - public void PutReadingFailTest() - { - var latest = controller.GetLatestReading(); - var content = ((OkNegotiatedContentResult)latest).Content; - var actionResult = controller.PutReading(content.Id, null); - Assert.AreEqual(typeof(BadRequestResult), actionResult.GetType()); - } - - [TestMethod()] - public void DeleteReadingPassTest() - { - var latest = controller.GetLatestReading(); - var content = ((OkNegotiatedContentResult)latest).Content; - var actionResult = controller.DeleteReading(content.Id); - var reading = controller.GetReading(content.Id); - Assert.IsInstanceOfType(reading, typeof(NotFoundResult)); - } - - [TestMethod()] - public void DeleteReadingFailTest() - { - var actionResult = controller.DeleteReading(1337); - Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); - } - } -} \ No newline at end of file diff --git a/PollutometerWebApi.Tests/SqlOperatorTests.cs b/PollutometerWebApi.Tests/SqlOperatorTests.cs deleted file mode 100644 index 2930679..0000000 --- a/PollutometerWebApi.Tests/SqlOperatorTests.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using PollutometerWebApi.Models; -using System; - -namespace PollutometerWebApi.Tests -{ - [TestClass()] - public class SqlOperatorTests - { - [TestMethod()] - public void GetReadingsTest() - { - var readings = SqlOperator.GetReadings("SELECT * FROM Readings"); - Assert.IsTrue(readings.Count >= 1); - } - - [TestMethod()] - public void PostReadingTest() - { - var newReading = new Reading - { - TimeStamp = (int)DateTimeOffset.Now.ToUnixTimeSeconds(), - Co = 0.0, - No = 0.0, - So = 0.0 - }; - SqlOperator.PostReading(newReading); - var command = "SELECT * FROM Readings " + - "WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)"; - var latestReading = SqlOperator.GetReadings(command)[0]; - var command2 = $"SELECT * FROM Readings WHERE Id={latestReading.Id}"; - var reading = SqlOperator.GetReadings(command2)[0]; - Assert.AreEqual(newReading.TimeStamp, reading.TimeStamp); - } - - [TestMethod()] - public void PutReadingTest() - { - var newReading = new Reading - { - TimeStamp = (int)DateTimeOffset.Now.ToUnixTimeSeconds(), - Co = 0.5, - No = 0.5, - So = 0.5 - - }; - var command = "SELECT * FROM Readings " + - "WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)"; - var latestReading = SqlOperator.GetReadings(command)[0]; - SqlOperator.PutReading(latestReading.Id, newReading); - var command2 = $"SELECT * FROM Readings WHERE Id={latestReading.Id}"; - var reading = SqlOperator.GetReadings(command2)[0]; - Assert.AreEqual(newReading.TimeStamp, reading.TimeStamp); - } - - [TestMethod()] - public void DeleteReadingTest() - { - var command = "SELECT * FROM Readings " + - "WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)"; - var latestReading = SqlOperator.GetReadings(command)[0]; - SqlOperator.DeleteReading(latestReading.Id); - var command2 = $"SELECT * FROM Readings WHERE Id={latestReading.Id}"; - var readings = SqlOperator.GetReadings(command2); - Assert.IsTrue(readings.Count == 0); - } - } -} \ No newline at end of file diff --git a/PollutometerWebApi.Tests/app.config b/PollutometerWebApi.Tests/app.config deleted file mode 100644 index 4429813..0000000 --- a/PollutometerWebApi.Tests/app.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/PollutometerWebApi.Tests/packages.config b/PollutometerWebApi.Tests/packages.config deleted file mode 100644 index 7472064..0000000 --- a/PollutometerWebApi.Tests/packages.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3