Skip to content

Commit

Permalink
Merge pull request #3 from aloisdg/dev
Browse files Browse the repository at this point in the history
Feat: Allow the use of equality members. Close #2
  • Loading branch information
aloisdg committed Sep 2, 2015
2 parents 6035869 + 5969431 commit d10148e
Show file tree
Hide file tree
Showing 17 changed files with 576 additions and 20 deletions.
9 changes: 6 additions & 3 deletions SharpResume.Tests/SharpResume.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.3.0.0-beta-3\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="SharpResume">
<HintPath>..\packages\SharpResume.1.0.0\lib\SharpResume.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<Choose>
Expand All @@ -69,6 +66,12 @@
<None Include="packages.config" />
<None Include="resume.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharpResume\SharpResume.csproj">
<Project>{c207a6eb-840f-4501-87b3-029ad9c9a212}</Project>
<Name>SharpResume</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions SharpResume.Tests/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,13 @@ public void TestCoursesCount()
var educations = _expected.education.ToObject<List<Education>>();
Assert.AreEqual(educations.Count, _resume.Education.Length);
}

[Test]
public void TestEquals()
{
var e1 = new Resume { Basics = new Basics { Name = "Alois" } };
var e2 = new Resume { Basics = new Basics { Name = "Alois" } };
Assert.AreEqual(e1, e2);
}
}
}
1 change: 0 additions & 1 deletion SharpResume.Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
<packages>
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="NUnit" version="3.0.0-beta-3" targetFramework="net45" />
<package id="SharpResume" version="1.0.0" targetFramework="net45" />
</packages>
42 changes: 41 additions & 1 deletion SharpResume/Model/Award.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,51 @@

namespace SharpResume.Model
{
public class Award
public class Award : IEquatable<Award>
{
public string Title { get; set; }
public DateTime Date { get; set; }
public string Awarder { get; set; }
public string Summary { get; set; }

public bool Equals(Award other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(Title, other.Title)
&& Date.Equals(other.Date)
&& string.Equals(Awarder, other.Awarder)
&& string.Equals(Summary, other.Summary);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Award)obj);
}

public override int GetHashCode()
{
unchecked
{
var hashCode = (Title != null ? Title.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Date.GetHashCode();
hashCode = (hashCode * 397) ^ (Awarder != null ? Awarder.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Summary != null ? Summary.GetHashCode() : 0);
return hashCode;
}
}

public static bool operator ==(Award left, Award right)
{
return Equals(left, right);
}

public static bool operator !=(Award left, Award right)
{
return !Equals(left, right);
}
}
}
54 changes: 53 additions & 1 deletion SharpResume/Model/Basics.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;

namespace SharpResume.Model
{
public class Basics
public class Basics : IEquatable<Basics>
{
public string Name { get; set; }
public string Label { get; set; }
Expand All @@ -11,5 +13,55 @@ public class Basics
public string Summary { get; set; }
public Location Location { get; set; }
public Profile[] Profiles { get; set; }

public bool Equals(Basics other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(Name, other.Name)
&& string.Equals(Label, other.Label)
&& string.Equals(Picture, other.Picture)
&& string.Equals(Email, other.Email)
&& string.Equals(Phone, other.Phone)
&& string.Equals(Website, other.Website)
&& string.Equals(Summary, other.Summary)
&& Equals(Location, other.Location)
&& Equals(Profiles, other.Profiles);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Basics)obj);
}

public override int GetHashCode()
{
unchecked
{
var hashCode = (Name != null ? Name.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Label != null ? Label.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Picture != null ? Picture.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Email != null ? Email.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Phone != null ? Phone.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Website != null ? Website.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Summary != null ? Summary.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Location != null ? Location.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Profiles != null ? Profiles.GetHashCode() : 0);
return hashCode;
}
}

public static bool operator ==(Basics left, Basics right)
{
return Equals(left, right);
}

public static bool operator !=(Basics left, Basics right)
{
return !Equals(left, right);
}
}
}
49 changes: 48 additions & 1 deletion SharpResume/Model/Education.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,60 @@
using System;
using SharpResume.Dateable;

namespace SharpResume.Model
{
public class Education : ADateable
public class Education : ADateable, IEquatable<Education>
{
public string Institution { get; set; }
public string Area { get; set; }
public string StudyType { get; set; }
public string Gpa { get; set; }
public string[] Courses { get; set; }

public bool Equals(Education other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(Institution, other.Institution)
&& string.Equals(Area, other.Area)
&& string.Equals(StudyType, other.StudyType)
&& string.Equals(Gpa, other.Gpa)
&& Equals(Courses, other.Courses)
&& Start.Equals(other.Start)
&& End.Equals(other.End);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Education) obj);
}

public override int GetHashCode()
{
unchecked
{
var hashCode = (Institution != null ? Institution.GetHashCode() : 0);
hashCode = (hashCode*397) ^ (Area != null ? Area.GetHashCode() : 0);
hashCode = (hashCode*397) ^ (StudyType != null ? StudyType.GetHashCode() : 0);
hashCode = (hashCode*397) ^ (Gpa != null ? Gpa.GetHashCode() : 0);
hashCode = (hashCode*397) ^ (Courses != null ? Courses.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Start.GetHashCode();
hashCode = (hashCode * 397) ^ End.GetHashCode();
return hashCode;
}
}

public static bool operator ==(Education left, Education right)
{
return Equals(left, right);
}

public static bool operator !=(Education left, Education right)
{
return !Equals(left, right);
}
}
}
37 changes: 36 additions & 1 deletion SharpResume/Model/Interest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
using System;

namespace SharpResume.Model
{
public class Interest
public class Interest : IEquatable<Interest>
{
public string Name { get; set; }
public string[] Keywords { get; set; }

public bool Equals(Interest other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(Name, other.Name) && Equals(Keywords, other.Keywords);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Interest)obj);
}

public override int GetHashCode()
{
unchecked
{
return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ (Keywords != null ? Keywords.GetHashCode() : 0);
}
}

public static bool operator ==(Interest left, Interest right)
{
return Equals(left, right);
}

public static bool operator !=(Interest left, Interest right)
{
return !Equals(left, right);
}
}
}
37 changes: 36 additions & 1 deletion SharpResume/Model/Language.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
using System;

namespace SharpResume.Model
{
public class Language
public class Language : IEquatable<Language>
{
public string Name { get; set; }
public string Fluency { get; set; }

public bool Equals(Language other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(Name, other.Name) && string.Equals(Fluency, other.Fluency);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Language)obj);
}

public override int GetHashCode()
{
unchecked
{
return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ (Fluency != null ? Fluency.GetHashCode() : 0);
}
}

public static bool operator ==(Language left, Language right)
{
return Equals(left, right);
}

public static bool operator !=(Language left, Language right)
{
return !Equals(left, right);
}
}
}
44 changes: 43 additions & 1 deletion SharpResume/Model/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,54 @@

namespace SharpResume.Model
{
public class Location
public class Location : IEquatable<Location>
{
public string Address { get; set; }
public string PostalCode { get; set; }
public string City { get; set; }
public string CountryCode { get; set; }
public string Region { get; set; }

public bool Equals(Location other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return string.Equals(Address, other.Address)
&& string.Equals(PostalCode, other.PostalCode)
&& string.Equals(City, other.City)
&& string.Equals(CountryCode, other.CountryCode)
&& string.Equals(Region, other.Region);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Location)obj);
}

public override int GetHashCode()
{
unchecked
{
var hashCode = (Address != null ? Address.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (PostalCode != null ? PostalCode.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (CountryCode != null ? CountryCode.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Region != null ? Region.GetHashCode() : 0);
return hashCode;
}
}

public static bool operator ==(Location left, Location right)
{
return Equals(left, right);
}

public static bool operator !=(Location left, Location right)
{
return !Equals(left, right);
}
}
}
Loading

0 comments on commit d10148e

Please sign in to comment.