public void SingleItemHoldsValue() { { SingleItem <MyInt> si = (MyInt)42; Assert.Equal((MyInt)42, si.Value); Assert.Equal((MyInt)42, (MyInt)si); } { MyInt i = 42; SingleItem <MyInt> si = i; Assert.Equal(i, si.Value); MyInt o = si; Assert.Equal(i, o); } { string i = "foo"; SingleItem <string> si = i; Assert.Equal(i, si.Value); string o = si; Assert.Equal(i, o); } { MyFalseEquatable i = new MyFalseEquatable(); SingleItem <MyFalseEquatable> si = i; Assert.Same(i, si.Value); MyFalseEquatable o = si; Assert.Same(i, o); } }
public void SingleItemEqualsCallsItemEquals() { { MyFalseEquatable e = new MyFalseEquatable(); SingleItem <MyFalseEquatable> si1 = e; SingleItem <MyFalseEquatable> si2 = e; Assert.False(si1.Equals(si2)); } { SingleItem <MyTrueEquatable> si1 = new MyTrueEquatable(); SingleItem <MyTrueEquatable> si2 = new MyTrueEquatable(); Assert.True(si1.Equals(si2)); } }
public void ItemListHoldsValues() { { ItemList <int> il = new ItemList <int> { 3, 4, 5 }; Assert.Equal(3, il.Count); Assert.Equal(3, il[0]); Assert.Equal(4, il[1]); Assert.Equal(5, il[2]); } { var i = new List <int> { 3, 4, 5 }; ItemList <int> il = new ItemList <int>(i); IList <int> o = il; Assert.Equal(i, o); } { var i = new List <SingleValue <int> > { 3, 4, 5 }; ItemList <SingleValue <int> > il = new ItemList <SingleValue <int> >(i); IList <SingleValue <int> > o = il; Assert.Equal(i, o); } { MyFalseEquatable i = new MyFalseEquatable(); ItemList <MyFalseEquatable> il = new ItemList <MyFalseEquatable> { i }; MyFalseEquatable o = il[0]; Assert.Same(i, o); } }
public void ItemListEqualsCallsItemEquals() { { MyFalseEquatable e = new MyFalseEquatable(); ItemList <MyFalseEquatable> si1 = new ItemList <MyFalseEquatable> { e }; ItemList <MyFalseEquatable> si2 = new ItemList <MyFalseEquatable> { e }; Assert.False(si1.Equals(si2)); } { ItemList <MyTrueEquatable> si1 = new ItemList <MyTrueEquatable> { new MyTrueEquatable() }; ItemList <MyTrueEquatable> si2 = new ItemList <MyTrueEquatable> { new MyTrueEquatable() }; Assert.True(si1.Equals(si2)); } }