Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -11,6 +12,8 @@
<AssemblyName>CodingChallenge.FamilyTree.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -29,6 +32,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Given.Common">
<HintPath>..\packages\Given.0.1.5034.35988\lib\net40\Given.Common.dll</HintPath>
Expand Down Expand Up @@ -70,7 +76,16 @@
<Name>CodingChallenge.FamilyTree</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- 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">
Expand Down
40 changes: 35 additions & 5 deletions CodingChallenge.FamilyTree.Tests/Tests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Given.Common;
using System;
using System.Collections.Generic;
using Xunit;

namespace CodingChallenge.FamilyTree.Tests
Expand All @@ -10,25 +12,53 @@ public class TreeTests
[Theory]
public void if_the_person_exists_in_tree_the_result_should_be_january()
{
var tree = FamilyTreeGenerator.Make();
var result = new Solution().GetBirthMonth(tree, "Joe");
result.ShouldEqual("January");
var Ted = new Person
{
Name = "Ted",
Birthday = DateTime.Parse("5/5/1950"),
Descendants = new List<Person>
{
new Person
{
Name = "Sally",
Birthday = DateTime.Parse("4/5/1965"),
Descendants = new List<Person>
{
new Person {Name = "Bob", Birthday = DateTime.Parse("9/5/1995")}
}
},
new Person
{
Name = "Jim",
Birthday = DateTime.Parse("3/5/1966"),
Descendants = new List<Person>
{
new Person {Name = "Joe", Birthday = DateTime.Parse("1/5/1985")},
new Person {Name = "George", Birthday = DateTime.Parse("6/5/1995")}
}
}
}
};


var result = new Solution().GetBirthMonth(Ted, "Joe");
Assert.Equal(result, "January");
}

[Theory]
public void if__the_person_exists_at_the_top_tree_the_result_should_be_may()
{
var tree = FamilyTreeGenerator.Make();
var result = new Solution().GetBirthMonth(tree, "Ted");
result.ShouldEqual("May");
Assert.Equal(result, "May");
}

[Theory]
public void if_the_person_does_not_exist_in_the_tree_the_result_should_be_empty()
{
var tree = FamilyTreeGenerator.Make();
var result = new Solution().GetBirthMonth(tree, "Jeebus");
result.ShouldEqual("");
Assert.Equal(result, "");
}
}
}
1 change: 1 addition & 0 deletions CodingChallenge.FamilyTree.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<package id="xunit.core" version="2.1.0" targetFramework="net45" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net45" />
</packages>
3 changes: 3 additions & 0 deletions CodingChallenge.FamilyTree/CodingChallenge.FamilyTree.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
18 changes: 17 additions & 1 deletion CodingChallenge.FamilyTree/Solution.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
using System;
using System.Linq;

namespace CodingChallenge.FamilyTree
{
public class Solution
{
public string GetBirthMonth(Person person, string descendantName)
{
throw new NotImplementedException();
bool contains = person.Descendants.Any(d => d.Name == descendantName);
//if any of the decendants of the person have this name, then return true

if (contains)
{
Person myPerson = person.Descendants.Find(d => d.Name == descendantName);

string birthMonth = myPerson.Birthday.ToString("MMMM");

return birthMonth;
}

else
{
throw new NotImplementedException();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CodingChallenge.PirateSpeak\CodingChallenge.PirateSpeak.csproj">
<Project>{467D3021-CBF9-4383-8886-72520FC0F274}</Project>
<Name>CodingChallenge.PirateSpeak</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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.
Expand Down
16 changes: 2 additions & 14 deletions CodingChallenge.sln
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodingChallenge.FamilyTree", "CodingChallenge.FamilyTree\CodingChallenge.FamilyTree.csproj", "{F43D3813-4615-48F4-95D4-44CE7C49B40F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodingChallenge.FamilyTree.Tests", "CodingChallenge.FamilyTree.Tests\CodingChallenge.FamilyTree.Tests.csproj", "{595D7E79-10C8-449E-9A44-0C158F944CC7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodingChallenge.PirateSpeak", "CodingChallenge.PirateSpeak\CodingChallenge.PirateSpeak.csproj", "{467D3021-CBF9-4383-8886-72520FC0F274}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodingChallenge.PirateSpeak.Tests", "CodingChallenge.PirateSpeak.Tests\CodingChallenge.PirateSpeak.Tests.csproj", "{F016CA98-6DCE-4EAE-A70E-2A1F4583AA16}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -25,14 +21,6 @@ Global
{595D7E79-10C8-449E-9A44-0C158F944CC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{595D7E79-10C8-449E-9A44-0C158F944CC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{595D7E79-10C8-449E-9A44-0C158F944CC7}.Release|Any CPU.Build.0 = Release|Any CPU
{467D3021-CBF9-4383-8886-72520FC0F274}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{467D3021-CBF9-4383-8886-72520FC0F274}.Debug|Any CPU.Build.0 = Debug|Any CPU
{467D3021-CBF9-4383-8886-72520FC0F274}.Release|Any CPU.ActiveCfg = Release|Any CPU
{467D3021-CBF9-4383-8886-72520FC0F274}.Release|Any CPU.Build.0 = Release|Any CPU
{F016CA98-6DCE-4EAE-A70E-2A1F4583AA16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F016CA98-6DCE-4EAE-A70E-2A1F4583AA16}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F016CA98-6DCE-4EAE-A70E-2A1F4583AA16}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F016CA98-6DCE-4EAE-A70E-2A1F4583AA16}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down