Skip to content

Commit a41b04a

Browse files
committed
Added test project
More importantly, I got a strategy to keep track of time spent in a directory. I've begun implementing the database part.
1 parent e8f91da commit a41b04a

15 files changed

+402
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ local.properties
6464
*.dotCover
6565

6666
## TODO: If you have NuGet Package Restore enabled, uncomment this
67-
#packages/
67+
packages/
6868

6969
# Visual C++ cache files
7070
ipch/

.nuget/NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<solution>
4+
<add key="disableSourceControlIntegration" value="true" />
5+
</solution>
6+
</configuration>

.nuget/NuGet.exe

605 KB
Binary file not shown.

.nuget/NuGet.targets

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
5+
6+
<!-- Enable the restore command to run before builds -->
7+
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
8+
9+
<!-- Property that enables building a package from a project -->
10+
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
11+
12+
<!-- Download NuGet.exe if it does not already exist -->
13+
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
14+
</PropertyGroup>
15+
16+
<ItemGroup Condition=" '$(PackageSources)' == '' ">
17+
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
18+
<!--
19+
<PackageSource Include="https://nuget.org/api/v2/" />
20+
<PackageSource Include="https://my-nuget-source/nuget/" />
21+
-->
22+
</ItemGroup>
23+
24+
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
25+
<!-- Windows specific commands -->
26+
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
27+
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
28+
<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
29+
</PropertyGroup>
30+
31+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
32+
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
33+
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
34+
<PackagesConfig>packages.config</PackagesConfig>
35+
<PackagesDir>$(SolutionDir)packages</PackagesDir>
36+
</PropertyGroup>
37+
38+
<PropertyGroup>
39+
<!-- NuGet command -->
40+
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath>
41+
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
42+
43+
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
44+
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
45+
46+
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
47+
48+
<!-- Commands -->
49+
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" -o "$(PackagesDir)"</RestoreCommand>
50+
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
51+
52+
<!-- Make the build depend on restore packages -->
53+
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
54+
RestorePackages;
55+
$(BuildDependsOn);
56+
</BuildDependsOn>
57+
58+
<!-- Make the build depend on restore packages -->
59+
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
60+
$(BuildDependsOn);
61+
BuildPackage;
62+
</BuildDependsOn>
63+
</PropertyGroup>
64+
65+
<Target Name="CheckPrerequisites">
66+
<!-- Raise an error if we're unable to locate nuget.exe -->
67+
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
68+
<SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
69+
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
70+
</Target>
71+
72+
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
73+
<Exec Command="$(RestoreCommand)"
74+
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
75+
76+
<Exec Command="$(RestoreCommand)"
77+
LogStandardErrorAsError="true"
78+
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
79+
</Target>
80+
81+
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
82+
<Exec Command="$(BuildCommand)"
83+
Condition=" '$(OS)' != 'Windows_NT' " />
84+
85+
<Exec Command="$(BuildCommand)"
86+
LogStandardErrorAsError="true"
87+
Condition=" '$(OS)' == 'Windows_NT' " />
88+
</Target>
89+
90+
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
91+
<ParameterGroup>
92+
<OutputFilename ParameterType="System.String" Required="true" />
93+
</ParameterGroup>
94+
<Task>
95+
<Reference Include="System.Core" />
96+
<Using Namespace="System" />
97+
<Using Namespace="System.IO" />
98+
<Using Namespace="System.Net" />
99+
<Using Namespace="Microsoft.Build.Framework" />
100+
<Using Namespace="Microsoft.Build.Utilities" />
101+
<Code Type="Fragment" Language="cs">
102+
<![CDATA[
103+
try {
104+
OutputFilename = Path.GetFullPath(OutputFilename);
105+
106+
Log.LogMessage("Downloading latest version of NuGet.exe...");
107+
WebClient webClient = new WebClient();
108+
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
109+
110+
return true;
111+
}
112+
catch (Exception ex) {
113+
Log.LogErrorFromException(ex);
114+
return false;
115+
}
116+
]]>
117+
</Code>
118+
</Task>
119+
</UsingTask>
120+
121+
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
122+
<ParameterGroup>
123+
<EnvKey ParameterType="System.String" Required="true" />
124+
<EnvValue ParameterType="System.String" Required="true" />
125+
</ParameterGroup>
126+
<Task>
127+
<Using Namespace="System" />
128+
<Code Type="Fragment" Language="cs">
129+
<![CDATA[
130+
try {
131+
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
132+
}
133+
catch {
134+
}
135+
]]>
136+
</Code>
137+
</Task>
138+
</UsingTask>
139+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using Xunit;
3+
using Should;
4+
5+
namespace Jump.Location.Specs
6+
{
7+
public class DirectoryWaitPeriodSpec
8+
{
9+
[Fact]
10+
public void It_updates_the_records_weight_upon_CloseAndUpdate()
11+
{
12+
var now = DateTime.Now.AddMinutes(-3);
13+
var record = new Record("x::y", 0);
14+
var waitPeriod = new DirectoryWaitPeriod(record, now);
15+
16+
waitPeriod.CloseAndUpdate();
17+
18+
Assert.True(record.Weight > 0);
19+
}
20+
21+
[Fact]
22+
public void You_cant_call_CloseAndUpdate_twice()
23+
{
24+
var waitPeriod = new DirectoryWaitPeriod(new Record("x::y", 0), DateTime.Now);
25+
waitPeriod.CloseAndUpdate();
26+
Assert.Throws<InvalidOperationException>(() => waitPeriod.CloseAndUpdate());
27+
}
28+
}
29+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.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>{C0A231D4-4E62-4E22-BD81-EB8257B15D21}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Jump.Location.Specs</RootNamespace>
11+
<AssemblyName>Jump.Location.Specs</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
15+
<RestorePackages>true</RestorePackages>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
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="Should">
36+
<HintPath>..\packages\Should.1.1.12.0\lib\Should.dll</HintPath>
37+
</Reference>
38+
<Reference Include="System" />
39+
<Reference Include="System.Core" />
40+
<Reference Include="System.Xml.Linq" />
41+
<Reference Include="System.Data.DataSetExtensions" />
42+
<Reference Include="Microsoft.CSharp" />
43+
<Reference Include="System.Data" />
44+
<Reference Include="System.Xml" />
45+
<Reference Include="xunit">
46+
<HintPath>..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
47+
</Reference>
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="DirectoryWaitPeriodSpec.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<None Include="packages.config" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<ProjectReference Include="..\Jump.Location\Jump.Location.csproj">
58+
<Project>{813430AC-0181-4ACB-B731-C5F6578CEC64}</Project>
59+
<Name>Jump.Location</Name>
60+
</ProjectReference>
61+
</ItemGroup>
62+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
63+
<Import Project="$(SolutionDir)\.nuget\nuget.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>
Lines changed: 36 additions & 0 deletions
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("Jump.Location.Specs")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Hewlett-Packard")]
12+
[assembly: AssemblyProduct("Jump.Location.Specs")]
13+
[assembly: AssemblyCopyright("Copyright © Hewlett-Packard 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("360fefbe-2766-4418-8097-bb13a2ee7a1f")]
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")]

Jump.Location.Specs/packages.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Should" version="1.1.12.0" />
4+
<package id="xunit" version="1.9.1" />
5+
</packages>

Jump.Location.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2012
44
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jump.Location", "Jump.Location\Jump.Location.csproj", "{813430AC-0181-4ACB-B731-C5F6578CEC64}"
55
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jump.Location.Specs", "Jump.Location.Specs\Jump.Location.Specs.csproj", "{C0A231D4-4E62-4E22-BD81-EB8257B15D21}"
7+
EndProject
68
Global
79
GlobalSection(SolutionConfigurationPlatforms) = preSolution
810
Debug|Any CPU = Debug|Any CPU
@@ -13,6 +15,10 @@ Global
1315
{813430AC-0181-4ACB-B731-C5F6578CEC64}.Debug|Any CPU.Build.0 = Debug|Any CPU
1416
{813430AC-0181-4ACB-B731-C5F6578CEC64}.Release|Any CPU.ActiveCfg = Release|Any CPU
1517
{813430AC-0181-4ACB-B731-C5F6578CEC64}.Release|Any CPU.Build.0 = Release|Any CPU
18+
{C0A231D4-4E62-4E22-BD81-EB8257B15D21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{C0A231D4-4E62-4E22-BD81-EB8257B15D21}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{C0A231D4-4E62-4E22-BD81-EB8257B15D21}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{C0A231D4-4E62-4E22-BD81-EB8257B15D21}.Release|Any CPU.Build.0 = Release|Any CPU
1622
EndGlobalSection
1723
GlobalSection(SolutionProperties) = preSolution
1824
HideSolutionNode = FALSE

Jump.Location/Database.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Jump.Location
2+
{
3+
class Database
4+
{
5+
}
6+
}

0 commit comments

Comments
 (0)