public void TestReturnList() { var set = new BinaryTreeSet <int>(); set.Add(1); set.Add(2); set.Add(3); CollectionAssert.AreEqual(new[] { 1, 2, 3 }, set.ToList()); }
public void TestIntersects() { var set = new BinaryTreeSet <int>(); set.Add(1); set.Add(2); set.Add(3); set.IntersectWith(new[] { 2, 3, 4, 5 }); CollectionAssert.AreEqual(new[] { 2, 3 }, set.ToList()); }
public void TestSerializeAndDeserialize() { var set = new BinaryTreeSet <int> { 3, 5, 7, 9, 11 }; var name = "some-name"; var stream = new MemoryStream(); var storageMock = new Mock <IStorage>(); storageMock.Setup(s => s.GetWriteStream(name)) .Returns(stream); storageMock.Setup(s => s.GetReadStream(name)) .Returns(stream); var serializer = new BinaryTreeSetSerializer(storageMock.Object); serializer.Save(name, set, closeStream: false); stream.Position = 0; var newSet = serializer.Load <int>(name); CollectionAssert.AreEqual(set.ToList(), newSet.ToList()); }