Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add unit tests for asp.net mvc code

  • Loading branch information...
commit 3db38d5fdaf4d28d6e9a9b3af1fa8db9a5c299ba 1 parent a9b642a
Dominique Plante dominiqueplante authored
27 src/SWTOR.Web.Tests/Controllers/APIControllerTest.cs
... ... @@ -0,0 +1,27 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Text;
  5 +using System.Web.Mvc;
  6 +using Microsoft.VisualStudio.TestTools.UnitTesting;
  7 +using SWTOR.Web.Controllers;
  8 +
  9 +namespace SWTOR.Web.Controllers.Tests
  10 +{
  11 + [TestClass]
  12 + public class APIControllerTest
  13 + {
  14 + [TestMethod]
  15 + public void Parse()
  16 + {
  17 + // Arrange
  18 + var controller = new APIController();
  19 +
  20 + // Act
  21 + ContentResult result = controller.ParseText(@"[03/17/2012 19:30:34] [@Argorash] [@Argorash] [Personal Vehicle {2176247043981312}] [RemoveEffect {836045448945478}: Personal Vehicle {2176247043981312}] ()") as ContentResult;
  22 +
  23 + // Assert
  24 + 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());
  25 + }
  26 + }
  27 +}
28 src/SWTOR.Web.Tests/Controllers/HomeControllerTest.cs
... ... @@ -0,0 +1,28 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Text;
  5 +using System.Web.Mvc;
  6 +using Microsoft.VisualStudio.TestTools.UnitTesting;
  7 +using SWTOR.Web.Controllers;
  8 +
  9 +namespace SWTOR.Web.Controllers.Tests
  10 +{
  11 + [TestClass]
  12 + public class HomeControllerTest
  13 + {
  14 + [TestMethod]
  15 + public void Index()
  16 + {
  17 + // Arrange
  18 + HomeController controller = new HomeController();
  19 +
  20 + // Act
  21 + ViewResult result = controller.Index() as ViewResult;
  22 +
  23 + // Assert
  24 + Assert.IsNotNull(result);
  25 +
  26 + }
  27 + }
  28 +}
35 src/SWTOR.Web.Tests/Properties/AssemblyInfo.cs
... ... @@ -0,0 +1,35 @@
  1 +using System.Reflection;
  2 +using System.Runtime.CompilerServices;
  3 +using System.Runtime.InteropServices;
  4 +
  5 +// General Information about an assembly is controlled through the following
  6 +// set of attributes. Change these attribute values to modify the information
  7 +// associated with an assembly.
  8 +[assembly: AssemblyTitle("SWTOR.Web.Tests")]
  9 +[assembly: AssemblyDescription("")]
  10 +[assembly: AssemblyConfiguration("")]
  11 +[assembly: AssemblyCompany("")]
  12 +[assembly: AssemblyProduct("SWTOR.Web.Tests")]
  13 +[assembly: AssemblyCopyright("Copyright © 2012")]
  14 +[assembly: AssemblyTrademark("")]
  15 +[assembly: AssemblyCulture("")]
  16 +
  17 +// Setting ComVisible to false makes the types in this assembly not visible
  18 +// to COM components. If you need to access a type in this assembly from
  19 +// COM, set the ComVisible attribute to true on that type.
  20 +[assembly: ComVisible(false)]
  21 +
  22 +// The following GUID is for the ID of the typelib if this project is exposed to COM
  23 +[assembly: Guid("66340a94-86a7-47bb-ad19-c7e02f1cfe77")]
  24 +
  25 +// Version information for an assembly consists of the following four values:
  26 +//
  27 +// Major Version
  28 +// Minor Version
  29 +// Build Number
  30 +// Revision
  31 +//
  32 +// You can specify all the values or you can default the Build and Revision Numbers
  33 +// by using the '*' as shown below:
  34 +[assembly: AssemblyVersion("1.0.0.0")]
  35 +[assembly: AssemblyFileVersion("1.0.0.0")]
67 src/SWTOR.Web.Tests/SWTOR.Web.Tests.csproj
... ... @@ -0,0 +1,67 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3 + <PropertyGroup>
  4 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  5 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  6 + <ProductVersion>
  7 + </ProductVersion>
  8 + <SchemaVersion>2.0</SchemaVersion>
  9 + <ProjectGuid>{0F4623EF-6ECB-488A-AB8D-369A131C4044}</ProjectGuid>
  10 + <OutputType>Library</OutputType>
  11 + <AppDesignerFolder>Properties</AppDesignerFolder>
  12 + <RootNamespace>SWTOR.Web.Tests</RootNamespace>
  13 + <AssemblyName>SWTOR.Web.Tests</AssemblyName>
  14 + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
  15 + <FileAlignment>512</FileAlignment>
  16 + <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
  17 + </PropertyGroup>
  18 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  19 + <DebugSymbols>true</DebugSymbols>
  20 + <DebugType>full</DebugType>
  21 + <Optimize>false</Optimize>
  22 + <OutputPath>bin\Debug\</OutputPath>
  23 + <DefineConstants>DEBUG;TRACE</DefineConstants>
  24 + <ErrorReport>prompt</ErrorReport>
  25 + <WarningLevel>4</WarningLevel>
  26 + </PropertyGroup>
  27 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  28 + <DebugType>pdbonly</DebugType>
  29 + <Optimize>true</Optimize>
  30 + <OutputPath>bin\Release\</OutputPath>
  31 + <DefineConstants>TRACE</DefineConstants>
  32 + <ErrorReport>prompt</ErrorReport>
  33 + <WarningLevel>4</WarningLevel>
  34 + </PropertyGroup>
  35 + <ItemGroup>
  36 + <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
  37 + <Reference Include="System" />
  38 + <Reference Include="System.Core">
  39 + <RequiredTargetFramework>3.5</RequiredTargetFramework>
  40 + </Reference>
  41 + <Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
  42 + </ItemGroup>
  43 + <ItemGroup>
  44 + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
  45 + <Visible>False</Visible>
  46 + </CodeAnalysisDependentAssemblyPaths>
  47 + </ItemGroup>
  48 + <ItemGroup>
  49 + <Compile Include="Controllers\APIControllerTest.cs" />
  50 + <Compile Include="Controllers\HomeControllerTest.cs" />
  51 + <Compile Include="Properties\AssemblyInfo.cs" />
  52 + </ItemGroup>
  53 + <ItemGroup>
  54 + <ProjectReference Include="..\SWTOR.Web\SWTOR.Web.csproj">
  55 + <Project>{F217B7A9-EEF9-48AF-944E-15D915A8CDF4}</Project>
  56 + <Name>SWTOR.Web</Name>
  57 + </ProjectReference>
  58 + </ItemGroup>
  59 + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  60 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  61 + Other similar extension points exist, see Microsoft.Common.targets.
  62 + <Target Name="BeforeBuild">
  63 + </Target>
  64 + <Target Name="AfterBuild">
  65 + </Target>
  66 + -->
  67 +</Project>

0 comments on commit 3db38d5

Please sign in to comment.
Something went wrong with that request. Please try again.