Skip to content

Commit

Permalink
#13 Updating test solution and adding utilities test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bethune-bryant committed Jan 17, 2018
1 parent a8ec63b commit 78a0b14
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 33 deletions.
17 changes: 10 additions & 7 deletions TimeKeeper.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeKeeper", "TimeKeeper\TimeKeeper.csproj", "{6D4052C6-7C14-419F-9CDC-EBA6478FDE0F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeKeeperTests", "TimeKeeperTests\TimeKeeperTests.csproj", "{521C6DBE-C367-4D18-8D73-06ECF00DB14D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeKeeperTests", "TimeKeeperTests\TimeKeeperTests.csproj", "{531979F1-C99A-4CB1-B035-BBFA9BBC756F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -17,12 +17,15 @@ Global
{6D4052C6-7C14-419F-9CDC-EBA6478FDE0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D4052C6-7C14-419F-9CDC-EBA6478FDE0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D4052C6-7C14-419F-9CDC-EBA6478FDE0F}.Release|Any CPU.Build.0 = Release|Any CPU
{521C6DBE-C367-4D18-8D73-06ECF00DB14D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{521C6DBE-C367-4D18-8D73-06ECF00DB14D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{521C6DBE-C367-4D18-8D73-06ECF00DB14D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{521C6DBE-C367-4D18-8D73-06ECF00DB14D}.Release|Any CPU.Build.0 = Release|Any CPU
{531979F1-C99A-4CB1-B035-BBFA9BBC756F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{531979F1-C99A-4CB1-B035-BBFA9BBC756F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{531979F1-C99A-4CB1-B035-BBFA9BBC756F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{531979F1-C99A-4CB1-B035-BBFA9BBC756F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6A111079-99AB-4391-BA66-DA12A787B1E8}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion TimeKeeper/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace TimeKeeper
{
class Utilities
public class Utilities
{
private static RegistryKey baseRegistryKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default);
private static string subKey = "SOFTWARE\\bethune-bryant\\Timekeeper";
Expand Down
6 changes: 3 additions & 3 deletions TimeKeeperTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("TimeKeeperTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Hewlett-Packard Company")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TimeKeeperTests")]
[assembly: AssemblyCopyright("Copyright © Hewlett-Packard Company 2017")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -20,7 +20,7 @@
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("521c6dbe-c367-4d18-8d73-06ecf00db14d")]
[assembly: Guid("531979f1-c99a-4cb1-b035-bbfa9bbc756f")]

// Version information for an assembly consists of the following four values:
//
Expand Down
2 changes: 1 addition & 1 deletion TimeKeeperTests/SettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void SettingsTest()
Assert.AreEqual(0, test.TimeEntries.Count);
Assert.AreEqual(15, test.StillWorkingTime);
}

[TestMethod()]
public void LastUnclosedTaskTest()
{
Expand Down
34 changes: 24 additions & 10 deletions TimeKeeperTests/TimeKeeperTests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{521C6DBE-C367-4D18-8D73-06ECF00DB14D}</ProjectGuid>
<ProjectGuid>{531979F1-C99A-4CB1-B035-BBFA9BBC756F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TimeKeeperTests</RootNamespace>
Expand All @@ -16,6 +17,8 @@
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -35,6 +38,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<Choose>
Expand All @@ -43,25 +52,22 @@
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsTests.cs" />
<Compile Include="UtilitiesTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TimeKeeper\TimeKeeper.csproj">
<Project>{6D4052C6-7C14-419F-9CDC-EBA6478FDE0F}</Project>
<Name>TimeKeeper</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand All @@ -82,6 +88,14 @@
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<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\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.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.
<Target Name="BeforeBuild">
Expand Down
56 changes: 56 additions & 0 deletions TimeKeeperTests/UtilitiesTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TimeKeeper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TimeKeeper.Tests
{
[TestClass()]
public class UtilitiesTests
{
[TestMethod()]
public void GetWeekTest()
{
Assert.AreEqual(53, Utilities.GetWeek(new DateTime(1999, 1, 1)), "Year/Week wraparound.");
Assert.AreEqual(53, Utilities.GetWeek(new DateTime(1999, 1, 2)), "Year/Week wraparound.");
Assert.AreEqual(53, Utilities.GetWeek(new DateTime(1999, 1, 3)), "Year/Week wraparound.");
Assert.AreEqual(1, Utilities.GetWeek(new DateTime(1999, 1, 4)), "Year/Week wraparound.");
Assert.AreEqual(1, Utilities.GetWeek(new DateTime(1999, 1, 5)), "Year/Week wraparound.");
Assert.AreEqual(1, Utilities.GetWeek(new DateTime(1999, 1, 6)), "Year/Week wraparound.");
}

[TestMethod()]
public void ElapsedTimeStringTest()
{
DateTime now = DateTime.Now;

Assert.AreEqual("00:00", Utilities.ElapsedTimeString(now, now), "Zero time.");
Assert.AreEqual("02:00", Utilities.ElapsedTimeString(now, now.AddHours(2)), "Zero minutes.");
Assert.AreEqual("02:00", Utilities.ElapsedTimeString(now, now.AddHours(-2)), "Negative time.");
Assert.AreEqual("10:00", Utilities.ElapsedTimeString(now, now.AddHours(10)), "Double digit hours.");
Assert.AreEqual("15:00", Utilities.ElapsedTimeString(now, now.AddHours(15)), "Over 12 hours.");
Assert.AreEqual("02:01", Utilities.ElapsedTimeString(now, now.AddHours(2).AddMinutes(1)), "One minute.");
Assert.AreEqual("02:59", Utilities.ElapsedTimeString(now, now.AddHours(2).AddMinutes(59)), "59 minutes.");
}

[TestMethod()]
public void GetTimeTest()
{
DateTime now = DateTime.Now;
List<TimeEntry> entries = new List<TimeEntry>();

Assert.AreEqual(new TimeSpan(0,0,0), Utilities.GetTime(entries), "Empty list of entries.");

entries.Add(new TimeEntry("", "", "", now.AddHours(-4), now.AddHours(-2), ""));

Assert.AreEqual(new TimeSpan(2, 0, 0), Utilities.GetTime(entries), "One entry.");

entries.Add(new TimeEntry("", "", "", now.AddHours(-2)));

Assert.AreEqual(4, Utilities.GetTime(entries).TotalHours, 1.0 / 60.0, "Unclosed entry.");
}
}
}
11 changes: 0 additions & 11 deletions TimeKeeperTests/app.config

This file was deleted.

5 changes: 5 additions & 0 deletions TimeKeeperTests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net45" />
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net45" />
</packages>

0 comments on commit 78a0b14

Please sign in to comment.