Skip to content

Commit

Permalink
add unit tests for asp.net mvc code
Browse files Browse the repository at this point in the history
  • Loading branch information
dominiqueplante committed Apr 1, 2012
1 parent a9b642a commit 3db38d5
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/SWTOR.Web.Tests/Controllers/APIControllerTest.cs
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SWTOR.Web.Controllers;

namespace SWTOR.Web.Controllers.Tests
{
[TestClass]
public class APIControllerTest
{
[TestMethod]
public void Parse()
{
// Arrange
var controller = new APIController();

// Act
ContentResult result = controller.ParseText(@"[03/17/2012 19:30:34] [@Argorash] [@Argorash] [Personal Vehicle {2176247043981312}] [RemoveEffect {836045448945478}: Personal Vehicle {2176247043981312}] ()") as ContentResult;

// Assert
Assert.AreEqual("[{\"timestamp\":\"\\/Date(1332037834000)\\/\",\"source\":{\"isPlayer\":true,\"name\":\"Argorash\",\"number\":0},\"target\":{\"isPlayer\":true,\"name\":\"Argorash\",\"number\":0},\"ability\":{\"name\":\"Personal Vehicle\",\"number\":2176247043981312},\"event\":{\"name\":\"RemoveEffect\",\"number\":836045448945478},\"effect\":{\"subtype\":\"\",\"name\":\"Personal Vehicle\",\"number\":2176247043981312},\"result\":{\"amount\":0,\"isCritical\":false,\"name\":\"\",\"number\":0},\"defense\":{\"name\":\"\",\"number\":0},\"mitigation\":{\"amount\":0,\"isCritical\":false,\"name\":\"\",\"number\":0},\"threat\":0}]", result.Content.ToString());
}
}
}
28 changes: 28 additions & 0 deletions src/SWTOR.Web.Tests/Controllers/HomeControllerTest.cs
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SWTOR.Web.Controllers;

namespace SWTOR.Web.Controllers.Tests
{
[TestClass]
public class HomeControllerTest
{
[TestMethod]
public void Index()
{
// Arrange
HomeController controller = new HomeController();

// Act
ViewResult result = controller.Index() as ViewResult;

// Assert
Assert.IsNotNull(result);

}
}
}
35 changes: 35 additions & 0 deletions src/SWTOR.Web.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
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("SWTOR.Web.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SWTOR.Web.Tests")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[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("66340a94-86a7-47bb-ad19-c7e02f1cfe77")]

// 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.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
67 changes: 67 additions & 0 deletions src/SWTOR.Web.Tests/SWTOR.Web.Tests.csproj
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0F4623EF-6ECB-488A-AB8D-369A131C4044}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SWTOR.Web.Tests</RootNamespace>
<AssemblyName>SWTOR.Web.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\APIControllerTest.cs" />
<Compile Include="Controllers\HomeControllerTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SWTOR.Web\SWTOR.Web.csproj">
<Project>{F217B7A9-EEF9-48AF-944E-15D915A8CDF4}</Project>
<Name>SWTOR.Web</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

0 comments on commit 3db38d5

Please sign in to comment.