public void Equality_Mixed() { Id n1 = new NumberId(1); Id s1 = new StringId("1"); // Mixed Assert.IsFalse(n1.Equals(s1)); }
public void NumberId_CanBeUsedAsKey() { Id id1 = new NumberId(1); Id id2 = new NumberId(1); var hash = new HashSet <Id> { id1, id2 }; Assert.AreEqual(1, hash.Count); Id id3 = new NumberId(2); hash.Add(id3); Assert.AreEqual(2, hash.Count); }
public void Equality_Number() { Id n1 = new NumberId(1); Id n11 = new NumberId(1); Id n2 = new NumberId(2); // Number Assert.IsTrue(n1.Equals(n11)); Assert.IsTrue(n11.Equals(n1)); Assert.IsFalse(n1.Equals(n2)); Assert.IsFalse(n2.Equals(n1)); Assert.IsFalse(n2.Equals(null)); Assert.IsTrue(n1 == n11); Assert.IsTrue(n11 == n1); Assert.IsFalse(n1 == n2); Assert.IsFalse(n2 == n1); Assert.IsFalse(n2 == null); }
private bool Equals(NumberId other) { return(Value == other.Value); }
private void ParseLogEntry(XmlReader reader, List <ChangeSet> result) { var cs = new ChangeSet(); // revision -> Id var revision = ReadRevision(reader); cs.Id = revision; _tracking.BeginChangeSet(cs); // author -> Committer if (!reader.ReadToDescendant("author")) { throw new InvalidDataException("author"); } cs.Committer = reader.ReadString(); // date -> date if (!reader.ReadToNextSibling("date")) { throw new InvalidDataException("date"); } cs.Date = DateTime.Parse(reader.ReadString().Trim()); if (!reader.ReadToNextSibling("paths")) { throw new InvalidDataException("paths"); } if (reader.ReadToDescendant("path")) { do { var item = new ChangeItem(); var kind = reader.GetAttribute("kind"); if (kind != "file") { continue; } var action = reader.GetAttribute("action"); item.Kind = SvnActionToKindOfChange(action); if (item.IsRename() || item.IsAdd()) { // Both actions can mean a renaming or movement. var copyFromPath = GetStringAttribute(reader, "copyfrom-path"); if (copyFromPath != null) { var id = GetULongAttribute(reader, "copyfrom-rev"); var copyFromRev = new NumberId(id); item.FromServerPath = copyFromPath; } } else { Debug.Assert(string.IsNullOrEmpty(GetStringAttribute(reader, "copyfrom-path"))); Debug.Assert(string.IsNullOrEmpty(GetStringAttribute(reader, "copyfrom-rev"))); } // All attributes must have been read here. var path = reader.ReadString().Trim(); item.ServerPath = path; item.LocalPath = MapToLocalFile_ServerIsAbsolute(path); if (item.Kind == KindOfChange.Rename && item.FromServerPath == null) { // Wtf. This can happen. Just ignore it. } else { _tracking.TrackId(item); } } while (reader.ReadToNextSibling("path")); if (!reader.ReadToFollowing("msg")) { throw new InvalidDataException("msg"); } cs.Comment = reader.ReadString().Trim(); ParseWorkItemsFromComment(cs.WorkItems, cs.Comment); } // Applies all change set items and sets their id _tracking.ApplyChangeSet(cs.Items); result.Add(cs); }