public void TestContains_ArgNull() { var target = new CombinedDisposables(); new Action(() => target.Contains(null)).Should().Throw <ArgumentNullException>(); }
public void TestContains() { var item1 = new Mock <IDisposable>(); var item2 = new Mock <IDisposable>(); var item3 = new Mock <IDisposable>(); var item4 = new Mock <IDisposable>(); var item5 = new Mock <IDisposable>(); var target = new CombinedDisposables(reverse: true, removeDispose: false); target.Add(item1.Object); target.Add(item2.Object); target.Add(item3.Object); target.Add(item4.Object); target.Add(item5.Object); target.Should().HaveCount(5); target.Remove(item2.Object); target.Contains(item1.Object).Should().Be(true); target.Contains(item2.Object).Should().Be(false); target.Contains(item3.Object).Should().Be(true); target.Contains(item4.Object).Should().Be(true); target.Contains(item5.Object).Should().Be(true); target.Remove(item2.Object); // 同じオブジェクトを再度指定 target.Contains(item1.Object).Should().Be(true); target.Contains(item2.Object).Should().Be(false); target.Contains(item3.Object).Should().Be(true); target.Contains(item4.Object).Should().Be(true); target.Contains(item5.Object).Should().Be(true); target.Remove(item1.Object); target.Remove(item3.Object); target.Remove(item4.Object); target.Remove(item5.Object); target.Contains(item1.Object).Should().Be(false); target.Contains(item2.Object).Should().Be(false); target.Contains(item3.Object).Should().Be(false); target.Contains(item4.Object).Should().Be(false); target.Contains(item5.Object).Should().Be(false); }