Skip to content

Commit 45b7a7b

Browse files
committed
Unit Testing using jasmine-chutzpah
1 parent 726b3b5 commit 45b7a7b

File tree

6 files changed

+162
-0
lines changed

6 files changed

+162
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace jasmine_chutzpah
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
}
14+
}
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Framework": "jasmine",
3+
"References": [
4+
{
5+
"Path": "src",
6+
"Includes": ["*.js"]
7+
}
8+
],
9+
"Tests": [
10+
{ "Includes": ["*.spec.js"] }
11+
]
12+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{B303D105-FF28-4F88-9B2F-751FE1485E9D}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>jasmine_chutzpah</RootNamespace>
11+
<AssemblyName>jasmine-chutzpah</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Net.Http" />
42+
<Reference Include="System.Xml" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Folder Include="Properties\" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="Program.cs" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<Content Include="spec\index.spec.js" />
52+
<Content Include="src\index.js" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<None Include="chutzpah.json" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
59+
</ItemGroup>
60+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
61+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
62+
Other similar extension points exist, see Microsoft.Common.targets.
63+
<Target Name="BeforeBuild">
64+
</Target>
65+
<Target Name="AfterBuild">
66+
</Target>
67+
-->
68+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jasmine-chutzpah", "jasmine-chutzpah.csproj", "{B303D105-FF28-4F88-9B2F-751FE1485E9D}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{B303D105-FF28-4F88-9B2F-751FE1485E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B303D105-FF28-4F88-9B2F-751FE1485E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B303D105-FF28-4F88-9B2F-751FE1485E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B303D105-FF28-4F88-9B2F-751FE1485E9D}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference path="../src/index.js" />
2+
/// <reference path="jasmine.js" />
3+
4+
describe('MathLib', function () {
5+
describe('add', function () {
6+
it('adds two numbers together', function () {
7+
var mathLib = new MathLib();
8+
var result = mathLib.add(1, 2);
9+
expect(result).toEqual(3);
10+
});
11+
});
12+
13+
describe('multiply', function () {
14+
it('multiply two numbers', function () {
15+
var mathLib = new MathLib();
16+
var result = mathLib.multiply(3, 3);
17+
expect(result).toEqual(9);
18+
});
19+
});
20+
21+
describe('fibonacci', function () {
22+
it('generates a valid fibonacci sequence', function () {
23+
var mathLib = new MathLib();
24+
var result = mathLib.fibonacci(12);
25+
expect(result[12]).toEqual(144);
26+
});
27+
});
28+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var MathLib = function () {
2+
this.add = function (a, b) {
3+
return a + b;
4+
};
5+
6+
this.multiply = function (a, b) {
7+
return a * b;
8+
};
9+
10+
this.fibonacci = function (length) {
11+
var sequence = [0, 1];
12+
for (var i = 2; i <= length; ++i) {
13+
sequence[i] = sequence[i - 1] + sequence[i - 2];
14+
}
15+
return sequence;
16+
};
17+
};

0 commit comments

Comments
 (0)