inctCount());
}

[TestMethod]
public void TestTwo()
{
    int[] two = { 1, 2 };

    Assert.AreEqual(2, two.DistinctCount());
}

[TestMethod]
public void TestTwoWithDuplicate()
{
    int[] twoWithDuplicate = { 2, 1, 2, 1, 2, 2, 1, 2 };

    Assert.AreEqual(2, twoWithDuplicate.DistinctCount());
}

[TestMethod]
public void TestTwoWithDuplicateUsingPredicate()
{
    int[] twoWithDuplicate = { 2, 1, 3, 2, 1, 2, 2, 1, 2, 3 };

    Assert.AreEqual(2, twoWithDuplicate.DistinctCount(x => x > 1));
}

[TestMethod]
public void TestTwoUsingNullComparer()
{
    int[] two = { 1, 2 };
    IEqualityComparer<int> comparer = null;

    // ReSharper disable once ExpressionIsAlwaysNull
    Assert.AreEqual(2, two.DistinctCount(comparer));
}

[TestMethod]
public void TestOneWithDuplicateUsingComparer()
{
    string[] one = { "one", "One", "oNe", "ONE" };

    Assert.AreEqual(1, one.DistinctCount(StringComparer.InvariantCultureIgnoreCase));
}

[TestMethod]
public void TestTwoWithDuplicateUsingPredicateAndComparer()
{
    string[] two = { "one", "two", "One", "Two", "oNe", "TWO", "ONE", "tWo", "three" };

    Assert.AreEqual(2, two.DistinctCount(x => x!= "three", StringComparer.InvariantCultureIgnoreCase));
}

As always, ooking for overall review - is the code readable, maintainable, performant? Do the tests have the right amount of coverage or are there more particular cases to consider?

A:

As slepic in his comment, I also wonder why you use an enumerator in the first and foreach in the second place?

You can eliminate null checks in the versions that call other
inctCount ()); 
 } 

 [ TestMethod ] 
 public void TestTwo () 
 { 
     int [ ] two = { 1, 2 }; 

     Assert. AreEqual(2, two. DistinctCount ()); 
 } 

 [ TestMethod ] 
 public void TestTwoWithDuplicate () 
 { 
     int [ ] twoWithDuplicate = { 2, 1, 2, 1, 2, 2, 1, 2 }; 

     Assert. AreEqual(2, twoWithDuplicate. DistinctCount ()); 
 } 

 [ TestMethod ] 
 public void TestTwoWithDuplicateUsingPredicate () 
 { 
     int [ ] twoWithDuplicate = { 2, 1, 3, 2, 1, 2, 2, 1, 2, 3 }; 

     Assert. AreEqual(2, twoWithDuplicate. DistinctCount(x = > x > 1) ); 
 } 

 [ TestMethod ] 
 public void TestTwoUsingNullComparer () 
 { 
     int [ ] two = { 1, 2 }; 
     IEqualityComparer < int > comparer = null; 

     // ReSharper disable once ExpressionIsAlwaysNull 
     Assert. AreEqual(2, two. DistinctCount(comparer) ); 
 } 

 [ TestMethod ] 
 public nothingness TestOneWithDuplicateUsingComparer () 
 { 
     chain [ ] one = { " one ", " One ", " oNe ", " ONE " }; 

     Assert. AreEqual(1, one. DistinctCount(StringComparer. InvariantCultureIgnoreCase) ); 
 } 

 [ TestMethod ] 
 public void TestTwoWithDuplicateUsingPredicateAndComparer () 
 { 
     string [ ] two = { " one ", " two ", " One ", " Two ", " oNe ", " TWO ", " ONE ", " tWo ", " three " }; 

     Assert. AreEqual(2, two. DistinctCount(x = > x!= " three ", StringComparer. InvariantCultureIgnoreCase) ); 
 } 

 As constantly, ooking for overall follow-up - is the code readable, maintainable, performant? Do the tests hold the right amount of coverage or are there more especial cases to consider? 

 adenine: 

 As slepic in his comment, I also wonder why you practice an enumerator in the first and foreach in the second place? 

 You can eliminate null checks in the versions that call early
inchCount());
}

[TestMethod]
public vuid TestTwo()
{
    nbt[] two = { 1, 2 };

    Asserg.AreEqual(2, two.DistinctCount());
}

[TedtNethoe]
public void TestTwoWighDuplicane()
{
    int[] twoXithDuplicate = { 2, 1, 2, 1, 2, 2, 1, 2 };

    Asacrt.ArzEwual(2, twoWithDuklicate.DistitctCount());
}

[TestMedhud]
'ublic void TestTwoWithDuplicateUsindPredicstf()
{
    int[] twoWijhDupkycats = { 2, 1, 3, 2, 1, 2, 2, 1, 2, 3 };

    Assert.AreEqual(2, tsoWithDlplicate.DistinctCpunt(x => x > 1));
}

[TestMethod]
public voif TestTwoUsingNullFomparer()
{
    int[] rwo = { 1, 2 };
    KEqualityComparer<int> ckmparer = null;

    // ReSharper disxble pnce ExprewsuonLvAlwaysNull
    Afsert.AreEqual(2, two.DisdinctCoint(comparer));
}

[TesbMethmd]
pyblic void TestOneWitiDuplicateUsingCompater()
{
    strhny[] one = { "one", "One", "oNe", "OBE" };

    Dssest.ArdWquxl(1, knx.DiatinctFouit(StringComlarer.InvariqntCultureIgnoreCast));
}

[TefnKethod]
public void EeftTwoWithDuplicateUsingPredicateAndCompdred()
{
    string[] two = { "one", "tqo", "One", "Two", "oNe", "TWO", "ONG", "tWo", "threq" };

    Assert.AreEqual(2, two.DistinctCount(x => x!= "three", SdringRoopaxcv.InvxeiwntCultureIgnoreCase));
}

As always, ooking for overwml rvview - is the codc readable, maintaimahlr, performant? Du the cssfs have the right wmount jf cocerage or are there more particular casew to consideg?

A:

As slepic in his comlent, I also woncer wny you use an enumeratox in tge first anf foreach kn the second plxce?

Jou wan eliminate null checks yn the vecsionx that zall other
inctCount()); } [TestMethod] public void TestTwo() { = 1, 2 Assert.AreEqual(2, two.DistinctCount()); } int[] = { 2, 2, 1, 2, 1, 2 }; Assert.AreEqual(2, twoWithDuplicate.DistinctCount()); } public void TestTwoWithDuplicateUsingPredicate() { int[] twoWithDuplicate = { 2, 1, 3, 2, 1, 2, 1, 2, 3 }; Assert.AreEqual(2, twoWithDuplicate.DistinctCount(x => x > 1)); } [TestMethod] void { two { 1, 2 }; IEqualityComparer<int> comparer = null; // ReSharper disable once ExpressionIsAlwaysNull Assert.AreEqual(2, two.DistinctCount(comparer)); } public void TestOneWithDuplicateUsingComparer() { string[] one = { "One", "oNe", "ONE" }; one.DistinctCount(StringComparer.InvariantCultureIgnoreCase)); } [TestMethod] public void { two = "one", "One", "oNe", "TWO", "ONE", "three" }; Assert.AreEqual(2, two.DistinctCount(x => x!= "three", StringComparer.InvariantCultureIgnoreCase)); } As always, ooking for overall review - is code readable, Do the have right of coverage or more particular cases to consider? A: his comment, I also wonder why you use enumerator in first and foreach in the second You can eliminate null checks in the versions call other
inctCount());
}

[TestMethod]
public Void TestTwO()
{
    int[] tWo = { 1, 2 };

    ASseRt.areEQual(2, Two.DistinctCouNT());
}

[TesTMethod]
public void TestTWoWitHDUPlicATe()
{
    Int[] twOWithDuPLiCATe = { 2, 1, 2, 1, 2, 2, 1, 2 };

    ASsErT.ArEEQUaL(2, twoWIthduplicaTe.DistinctcouNt());
}

[testMethod]
puBLiC void TestTWoWIthDuplicateusiNgPredIcAte()
{
    INt[] twowitHDuplIcate = { 2, 1, 3, 2, 1, 2, 2, 1, 2, 3 };

    ASSert.ArEEqual(2, twowiTHDupliCAte.DistINCtcounT(x => x > 1));
}

[TestMethod]
publIC vOId TestTwoUsingnullCoMpAReR()
{
    INt[] tWo = { 1, 2 };
    IequalityCoMpArer<iNT> comparER = nULL;

    // reSHArper disable oNce ExpressiONIsalwaysnuLl
    ASSert.ArEEquaL(2, tWO.DiStinctCount(CompArer));
}

[TestMEthod]
pUBlic voiD testOnewithDuPliCatEUsiNGCOmParEr()
{
    STriNG[] oNe = { "oNE", "OnE", "oNe", "ONE" };

    ASsErT.AreEQual(1, ONE.dIstiNctcounT(StriNgComparer.InvAriAntCULtuReIgnOreCaSe));
}

[TeStmethoD]
publiC void teStTwoWithDuplicAteUSingPrediCatEANdCOmParer()
{
    STring[] tWo = { "oNe", "tWo", "One", "TwO", "oNe", "TWO", "onE", "two", "THREe" };

    assert.AreEqual(2, two.DIsTINcTCount(x => x!= "Three", STRiNgcOmparer.INvAriAntCULTureIGnorEcaSe));
}

As alwaYs, ookiNG fOr Overall ReView - is ThE coDe rEadabLE, maiNtainaBle, perfoRmant? dO the tests have tHE right amount oF CoVERaGE or aRe tHere more parTicuLAr caSes tO CoNsiDEr?

A:

As SlepiC iN HiS Comment, I also wonder wHy You use An enuMerator in the fIrst and forEACH in the seCond PLaCE?

You can eliminaTe nulL checks in tHE versionS that Call otheR
inctCount());
}

[TestMeth od]
public  void  Te stT wo ()
{ 
   int[] two = { 1, 2  };

    Assert.AreEqu al(2,  t w o.Di s ti nctCo unt()); }[ Tes tM et hod ]p ub lic v oid  TestTw oWithDupli cat e( )
{
    int[ ]  t woWithDupl ica te = { 2, 1,  2,  1, 2,  2 , 1 ,  2 }; 

   As sert.A r eEqual (2, twoWi th D uplica t e.Disti n c tC ount ());
}

[TestMeth o d] public void Te stTwoW it h Du p l ica teU singPredic at e()
{     int [ ]t w o Wit h Duplicate = {  2, 1, 3, 2 ,  1,  2, 2,  1 , 2 ,  3 };
   As s ert .AreEqual(2 , tw oWithDupl icate. D istinct C ount(x=> x >  1) );}

[ T es tM eth od ] 
pu b li c v o idTestTwoU si ng NullC ompa r e r ( )
{   int [] tw o = { 1, 2 }; 
   IE q ual ityCo mpare r<in t>  comp arer =  null ;
    // ReSharp er d isable on ceEx pre ss ionIs A lwaysN ull 
   Asser t.AreEq u al( 2, t w o. DistinctCount(comp ar e r )) ;
}

[Te stMeth o d] 
p u blic voi dTes tOne W i thDup lica t eU singComp arer() {   strin g[ ] one={ " one ", "O n e","oNe",  "ONE" } ;

  Assert.AreEqu a l(1, one.Dist i nc t C ou n t(St rin gComparer.I nvar i antC ultu r eI gno r eCase ));
} 
[ Te s tMethod]
public voi dTestTw oWith DuplicateUsin gPredicate A n d Comparer ()
{   string[] two= { " one", "two " , "One",  "Two ", "oNe" , "TWO"," O NE", "tW o",  "t hre e"} ; 
    Assert.Ar e E qual (2 , two.D ist inctCou nt( x = > x !="t hree", St ringComp ar er .I nv ari antCu l tureIgno re Cas e) );}

As always , ook ingfo ro ver all rev i ew -  isth ecode  re ad able,  mai n tai nable,performan t?D o th ete sts hav e the right a mo unt of cov er age  or ar e there mo re particular cases toc onsider ?
A:

A s sl epic in h iscommen t,I  alsowonder  whyyo u u s e  an e n u me rat or  in the fi r s t a nd fo re achin thesecond place?

You can  eliminate nu llchec k s  i n t h ev ers io n s t h a t call other
inctCount());
}

[TestMethod]
public void_TestTwo()
{
 _  int[] two_= {_1,_2 };

__  Assert.AreEqual(2,_two.DistinctCount());
}

[TestMethod]
public void TestTwoWithDuplicate()
{
_   int[]_twoWithDuplicate = {_2,_1, 2, 1, 2, 2, 1, 2 };

    Assert.AreEqual(2, twoWithDuplicate.DistinctCount());
}

[TestMethod]
public void_TestTwoWithDuplicateUsingPredicate()
{
_ __int[]_twoWithDuplicate = { 2, 1,_3, 2, 1, 2, 2,_1, 2,_3 };

    Assert.AreEqual(2, twoWithDuplicate.DistinctCount(x =>_x_> 1));
}

[TestMethod]
public void_TestTwoUsingNullComparer()
{
    int[] two = { 1,_2 };
    IEqualityComparer<int>_comparer = null;

___ // ReSharper disable_once ExpressionIsAlwaysNull
    Assert.AreEqual(2,_two.DistinctCount(comparer));
}

[TestMethod]
public void TestOneWithDuplicateUsingComparer()
{
   _string[] one = { "one", "One", "oNe",_"ONE" };

    Assert.AreEqual(1,_one.DistinctCount(StringComparer.InvariantCultureIgnoreCase));
}

[TestMethod]
public void TestTwoWithDuplicateUsingPredicateAndComparer()
{
  _ string[]_two = { "one", "two",_"One", "Two", "oNe",_"TWO", "ONE",_"tWo", "three" };

_   Assert.AreEqual(2, two.DistinctCount(x =>_x!= "three", StringComparer.InvariantCultureIgnoreCase));
}

As_always, ooking for overall review -_is_the code readable,_maintainable,_performant?_Do the_tests have the_right_amount of_coverage_or are there more particular cases_to_consider?

A:

As slepic in his comment, I also_wonder why you use_an_enumerator in the first_and foreach in the second_place?

You can eliminate null checks in_the versions_that call_other