Skip to content

Commit d346673

Browse files
clarify family tree challenge, add new pirate speak challenge
1 parent 9beb7f5 commit d346673

File tree

13 files changed

+476
-3
lines changed

13 files changed

+476
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.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>{595D7E79-10C8-449E-9A44-0C158F944CC7}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CodingChallenge.FamilyTree.Tests</RootNamespace>
11+
<AssemblyName>CodingChallenge.FamilyTree.Tests</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="Given.Common">
34+
<HintPath>..\packages\Given.0.1.5034.35988\lib\net40\Given.Common.dll</HintPath>
35+
</Reference>
36+
<Reference Include="Given.NUnit">
37+
<HintPath>..\packages\Given.NUnit.0.1.5034.35989\lib\net40\Given.NUnit.dll</HintPath>
38+
</Reference>
39+
<Reference Include="nunit.framework">
40+
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
41+
</Reference>
42+
<Reference Include="System" />
43+
<Reference Include="System.Core" />
44+
<Reference Include="System.Xml.Linq" />
45+
<Reference Include="System.Data.DataSetExtensions" />
46+
<Reference Include="Microsoft.CSharp" />
47+
<Reference Include="System.Data" />
48+
<Reference Include="System.Xml" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<Compile Include="Tests.cs" />
52+
<Compile Include="Properties\AssemblyInfo.cs" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<None Include="packages.config" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<ProjectReference Include="..\CodingChallenge.FamilyTree\CodingChallenge.FamilyTree.csproj">
59+
<Project>{F43D3813-4615-48F4-95D4-44CE7C49B40F}</Project>
60+
<Name>CodingChallenge.FamilyTree</Name>
61+
</ProjectReference>
62+
</ItemGroup>
63+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
64+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
65+
Other similar extension points exist, see Microsoft.Common.targets.
66+
<Target Name="BeforeBuild">
67+
</Target>
68+
<Target Name="AfterBuild">
69+
</Target>
70+
-->
71+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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("CodingChallenge.FamilyTree.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CodingChallenge.FamilyTree.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
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("13a6abeb-5a04-4540-a51d-a3ba09746928")]
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.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using Given.Common;
2+
using Given.NUnit;
3+
4+
namespace CodingChallenge.FamilyTree.Tests
5+
{
6+
public class person_exists_in_tree : Scenario
7+
{
8+
static Person _tree;
9+
static string _result;
10+
11+
given a_family_tree = () => _tree = FamilyTreeGenerator.Make();
12+
13+
when searching_the_tree_for_joes_birthday = () => _result = Solution.GetBirthMonth(_tree, "Joe");
14+
15+
[then]
16+
public void the_result_should_be_january()
17+
{
18+
_result.ShouldEqual("January");
19+
}
20+
}
21+
22+
public class person_exists_at_the_top_tree : Scenario
23+
{
24+
static Person _tree;
25+
static string _result;
26+
27+
given a_family_tree = () => _tree = FamilyTreeGenerator.Make();
28+
29+
when searching_the_tree_for_joes_birthday = () => _result = Solution.GetBirthMonth(_tree, "Ted");
30+
31+
[then]
32+
public void the_result_should_be_may()
33+
{
34+
_result.ShouldEqual("May");
35+
}
36+
}
37+
38+
public class person_does_not_exist_in_the_tree : Scenario
39+
{
40+
static Person _tree;
41+
static string _result;
42+
43+
given a_family_tree = () => _tree = FamilyTreeGenerator.Make();
44+
45+
when searching_the_tree_for_joes_birthday = () => _result = Solution.GetBirthMonth(_tree, "Jeebus");
46+
47+
[then]
48+
public void the_result_should_be_may()
49+
{
50+
_result.ShouldEqual("No descendant found.");
51+
}
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Given" version="0.1.5034.35988" targetFramework="net45" />
4+
<package id="Given.NUnit" version="0.1.5034.35989" targetFramework="net45" />
5+
<package id="NUnit" version="2.6.3" targetFramework="net45" />
6+
</packages>

CodingChallenge.FamilyTree/Person.cs

+48
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,56 @@ namespace CodingChallenge.FamilyTree
55
{
66
public class Person
77
{
8+
public Person()
9+
{
10+
Descendants = new List<Person>();
11+
}
12+
813
public string Name { get; set; }
914
public List<Person> Descendants { get; set; }
1015
public DateTime Birthday { get; set; }
1116
}
17+
18+
public static class FamilyTreeGenerator
19+
{
20+
public static Person Make()
21+
{
22+
var dateTime = DateTime.Parse("5/5/2010");
23+
return new Person
24+
{
25+
Name = "Ted",
26+
Birthday = DateTime.Parse("5/5/1950"),
27+
Descendants = new List<Person>
28+
{
29+
new Person
30+
{
31+
Name = "Sally",
32+
Birthday = DateTime.Parse("4/5/1965"),
33+
Descendants = new List<Person>
34+
{
35+
new Person {Name = "Bob", Birthday = DateTime.Parse("9/5/1995")}
36+
}
37+
},
38+
new Person
39+
{
40+
Name = "Jim",
41+
Birthday = DateTime.Parse("3/5/1966"),
42+
Descendants = new List<Person>
43+
{
44+
new Person {Name = "Joe", Birthday = DateTime.Parse("1/5/1985")},
45+
new Person {Name = "George", Birthday = DateTime.Parse("6/5/1995")}
46+
}
47+
}
48+
}
49+
};
50+
}
51+
}
52+
53+
public static class Solution
54+
{
55+
public static string GetBirthMonth(Person person, string descendantName)
56+
{
57+
throw new NotImplementedException();
58+
}
59+
}
1260
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.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>{F016CA98-6DCE-4EAE-A70E-2A1F4583AA16}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CodingChallenge.PirateSpeak.Tests</RootNamespace>
11+
<AssemblyName>CodingChallenge.PirateSpeak.Tests</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="Given.Common">
34+
<HintPath>..\packages\Given.0.1.5034.35988\lib\net40\Given.Common.dll</HintPath>
35+
</Reference>
36+
<Reference Include="Given.NUnit, Version=0.1.5034.35989, Culture=neutral, processorArchitecture=MSIL">
37+
<SpecificVersion>False</SpecificVersion>
38+
<HintPath>..\packages\Given.NUnit.0.1.5034.35989\lib\net40\Given.NUnit.dll</HintPath>
39+
</Reference>
40+
<Reference Include="nunit.framework">
41+
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
42+
</Reference>
43+
<Reference Include="System" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Xml.Linq" />
46+
<Reference Include="System.Data.DataSetExtensions" />
47+
<Reference Include="Microsoft.CSharp" />
48+
<Reference Include="System.Data" />
49+
<Reference Include="System.Xml" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<Compile Include="Class1.cs" />
53+
<Compile Include="Properties\AssemblyInfo.cs" />
54+
</ItemGroup>
55+
<ItemGroup>
56+
<None Include="packages.config" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<ProjectReference Include="..\CodingChallenge.PirateSpeak\CodingChallenge.PirateSpeak.csproj">
60+
<Project>{467D3021-CBF9-4383-8886-72520FC0F274}</Project>
61+
<Name>CodingChallenge.PirateSpeak</Name>
62+
</ProjectReference>
63+
</ItemGroup>
64+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
65+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
66+
Other similar extension points exist, see Microsoft.Common.targets.
67+
<Target Name="BeforeBuild">
68+
</Target>
69+
<Target Name="AfterBuild">
70+
</Target>
71+
-->
72+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using NUnit.Framework;
7+
8+
namespace CodingChallenge.PirateSpeak.Tests
9+
{
10+
[TestFixture]
11+
public class PirateSpeakTests
12+
{
13+
14+
[TestCase("trisf", new []{"first"}, Result = new[] {"first"})]
15+
[TestCase("oob", new[] {"bob", "baobob"}, Result = new string[0])]
16+
[TestCase("ainstuomn", new[] { "mountains", "hills", "mesa" }, Result = new[] { "mountains" })]
17+
[TestCase("oopl", new[] { "donkey", "pool", "horse", "loop" }, Result = new[] { "pool", "loop" })]
18+
[TestCase("oprst", new[] {"sport", "ports", "ball", "bat", "port"}, Result = new[] {"sport", "ports"})]
19+
public string[] TestPirateVocabulary(string jumble, string[] dictionary)
20+
{
21+
return new Solution().GetPossibleWords(jumble, dictionary);
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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("CodingChallenge.PirateSpeak.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CodingChallenge.PirateSpeak.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
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("b879076a-2c9a-4f05-bc3b-9d44f49ab26f")]
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.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Given" version="0.1.5034.35988" targetFramework="net45" />
4+
<package id="Given.NUnit" version="0.1.5034.35989" targetFramework="net45" />
5+
<package id="NUnit" version="2.6.3" targetFramework="net45" />
6+
</packages>

0 commit comments

Comments
 (0)