Permalink
Browse files

Added ObjectUtility and tests.

  • Loading branch information...
1 parent 92f8cb7 commit e3a9614ad5b6e125995bd0e26ecaa2b958b79967 @bgrainger bgrainger committed Feb 2, 2010
View
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logos.Utility", "src\Logos.Utility\Logos.Utility.csproj", "{F0BB7927-B2DB-4E37-9807-8E697CA09F32}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logos.Utility.Tests", "tests\Logos.Utility.Tests\Logos.Utility.Tests.csproj", "{F2594F76-66F9-4547-8B52-A89C0D48CE0E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F0BB7927-B2DB-4E37-9807-8E697CA09F32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F0BB7927-B2DB-4E37-9807-8E697CA09F32}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F0BB7927-B2DB-4E37-9807-8E697CA09F32}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F0BB7927-B2DB-4E37-9807-8E697CA09F32}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F2594F76-66F9-4547-8B52-A89C0D48CE0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F2594F76-66F9-4547-8B52-A89C0D48CE0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F2594F76-66F9-4547-8B52-A89C0D48CE0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F2594F76-66F9-4547-8B52-A89C0D48CE0E}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
Binary file not shown.
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{F0BB7927-B2DB-4E37-9807-8E697CA09F32}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Logos.Utility</RootNamespace>
+ <AssemblyName>Logos.Utility</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>full</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Release\Logos.Utility.XML</DocumentationFile>
+ <DebugSymbols>true</DebugSymbols>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ObjectImpl.cs" />
+ <Compile Include="ObjectUtility.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,45 @@
+
+using System;
+
+namespace Logos.Utility
+{
+ /// <summary>
+ /// Provides helper methods for implementing objects.
+ /// </summary>
+ public static class ObjectImpl
+ {
+ /// <summary>
+ /// Standard implementation of the equality operator.
+ /// </summary>
+ /// <param name="left">The left item.</param>
+ /// <param name="right">The right item.</param>
+ /// <returns>True if the items are equal.</returns>
+ public static bool OperatorEquality<T>(T left, T right)
+ where T : class, IEquatable<T>
+ {
+ if (object.ReferenceEquals(left, right))
+ return true;
+ else if (object.ReferenceEquals(left, null) || object.ReferenceEquals(right, null))
+ return false;
+ else
+ return left.Equals(right);
+ }
+
+ /// <summary>
+ /// Standard implementation of the inequality operator.
+ /// </summary>
+ /// <param name="left">The left item.</param>
+ /// <param name="right">The right item.</param>
+ /// <returns>True if the items are not equal.</returns>
+ public static bool OperatorInequality<T>(T left, T right)
+ where T : class, IEquatable<T>
+ {
+ if (object.ReferenceEquals(left, right))
+ return false;
+ else if (object.ReferenceEquals(left, null) || object.ReferenceEquals(right, null))
+ return true;
+ else
+ return !left.Equals(right);
+ }
+ }
+}
@@ -0,0 +1,22 @@
+
+using System;
+using System.Collections.Generic;
+
+namespace Logos.Utility
+{
+ /// <summary>
+ /// Provides methods for manipulating objects.
+ /// </summary>
+ public static class ObjectUtility
+ {
+ /// <summary>
+ /// Gets the hash code for the specified object.
+ /// </summary>
+ /// <param name="obj">The object for which to get a hash code.</param>
+ /// <returns>The hash code for the specified object, or zero if the object is null.</returns>
+ public static int GetHashCode<T>(T obj)
+ {
+ return obj == null ? 0 : obj.GetHashCode();
+ }
+ }
+}
@@ -0,0 +1,15 @@
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Logos.Utility")]
+[assembly: AssemblyDescription("Logos Bible Software Utility Library")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Logos Bible Software")]
+[assembly: AssemblyProduct("Logos.Utility")]
+[assembly: AssemblyCopyright("Copyright 2010 Logos Bible Software")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{F2594F76-66F9-4547-8B52-A89C0D48CE0E}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Logos.Utility.Tests</RootNamespace>
+ <AssemblyName>Logos.Utility.Tests</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="nunit.framework, Version=2.5.3.9345, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ObjectUtilityTests.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\Logos.Utility\Logos.Utility.csproj">
+ <Project>{F0BB7927-B2DB-4E37-9807-8E697CA09F32}</Project>
+ <Name>Logos.Utility</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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,18 @@
+
+using Logos.Utility;
+using NUnit.Framework;
+
+namespace Logos.Utility.Tests
+{
+ [TestFixture]
+ public class ObjectUtilityTests
+ {
+ [TestCase(null, 0)]
+ [TestCase(1, 1)]
+ [TestCase(2, 2)]
+ public void GetHashCode(object obj, int hashCode)
+ {
+ Assert.That(ObjectUtility.GetHashCode(obj), Is.EqualTo(hashCode));
+ }
+ }
+}
@@ -0,0 +1,15 @@
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Logos.Utility.Tests")]
+[assembly: AssemblyDescription("Logos Bible Software Utility Library tests")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Logos Bible Software")]
+[assembly: AssemblyProduct("Logos.Utility.Tests")]
+[assembly: AssemblyCopyright("Copyright 2010 Logos Bible Software")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit e3a9614

Please sign in to comment.