From f6f830d066635c91763dd1ae6248c8c189e6fe7e Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Mon, 20 Nov 2017 14:36:20 +0100 Subject: Added WebApi. --- .../Controllers/HomeControllerTest.cs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 AirPollutionWebApi.Tests/Controllers/HomeControllerTest.cs (limited to 'AirPollutionWebApi.Tests/Controllers/HomeControllerTest.cs') diff --git a/AirPollutionWebApi.Tests/Controllers/HomeControllerTest.cs b/AirPollutionWebApi.Tests/Controllers/HomeControllerTest.cs new file mode 100644 index 0000000..fdae606 --- /dev/null +++ b/AirPollutionWebApi.Tests/Controllers/HomeControllerTest.cs @@ -0,0 +1,35 @@ +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web.Mvc; +using AirPollutionWebApi; +using AirPollutionWebApi.Controllers; + +namespace AirPollutionWebApi.Tests.Controllers +{ + [TestFixture] + public class HomeControllerTest + { + [Test] + public void Index() + { + // Arrange + var controller = new HomeController(); + + // Act + var result = (ViewResult)controller.Index(); + + var mvcName = typeof(Controller).Assembly.GetName(); + var isMono = Type.GetType("Mono.Runtime") != null; + + var expectedVersion = mvcName.Version.Major + "." + mvcName.Version.Minor; + var expectedRuntime = isMono ? "Mono" : ".NET"; + + // Assert + Assert.AreEqual(expectedVersion, result.ViewData["Version"]); + Assert.AreEqual(expectedRuntime, result.ViewData["Runtime"]); + } + } +} -- cgit v1.2.3