Skip to content

Commit 8b16d9e

Browse files
authored
test implements interface (#2644)
1 parent 349b9ec commit 8b16d9e

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

MetaMorpheus/Test/ParameterTest.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Omics.Fragmentation.Peptide;
1313
using TaskLayer;
1414
using Transcriptomics.Digestion;
15+
using System;
1516

1617
namespace Test
1718
{
@@ -335,7 +336,7 @@ public static void ReadFileSpecificParametersFromToml_ThrowsOnUnknownDigestionAg
335336
Assert.Throws<MetaMorpheusException>(() => new FileSpecificParameters(fileSpecificTomlBad));
336337
}
337338

338-
class BadDigestionParams : IDigestionParams
339+
class BadDigestionParams : IDigestionParams, IEquatable<IDigestionParams>
339340
{
340341
public int MaxMissedCleavages { get; set; }
341342
public int MinLength { get; set; }
@@ -346,6 +347,32 @@ class BadDigestionParams : IDigestionParams
346347
public FragmentationTerminus FragmentationTerminus { get; }
347348
public CleavageSpecificity SearchModeType { get; }
348349
public IDigestionParams Clone(FragmentationTerminus? newTerminus = null) => this;
350+
351+
private bool Equals(BadDigestionParams other)
352+
{
353+
return MaxMissedCleavages == other.MaxMissedCleavages && MinLength == other.MinLength && MaxLength == other.MaxLength && MaxModificationIsoforms == other.MaxModificationIsoforms && MaxMods == other.MaxMods && DigestionAgent.Equals(other.DigestionAgent) && FragmentationTerminus == other.FragmentationTerminus && SearchModeType == other.SearchModeType;
354+
}
355+
356+
public bool Equals(IDigestionParams other)
357+
{
358+
if (other is null) return false;
359+
if (ReferenceEquals(this, other)) return true;
360+
if (other.GetType() != GetType()) return false;
361+
return Equals((BadDigestionParams)other);
362+
}
363+
364+
public override bool Equals(object obj)
365+
{
366+
if (obj is null) return false;
367+
if (ReferenceEquals(this, obj)) return true;
368+
if (obj.GetType() != GetType()) return false;
369+
return Equals((BadDigestionParams)obj);
370+
}
371+
372+
public override int GetHashCode()
373+
{
374+
return HashCode.Combine(MaxMissedCleavages, MinLength, MaxLength, MaxModificationIsoforms, MaxMods, DigestionAgent, (int)FragmentationTerminus, (int)SearchModeType);
375+
}
349376
}
350377
}
351-
}
378+
}

0 commit comments

Comments
 (0)