/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
namespace Lucene.Net.Support
{
[TestFixture]
public class TestEquatableList
{
///
/// This test shows that System.Collections.Generic.List is not suitable for determining uniqueness
/// when used in a HashSet. This is a difference between the Java and .NET BCL Lists. Since the equatable
/// behaviour of java.util.List.hashCode() in Java is relied upon for the the Java Lucene implementation,
/// a correct port must use an equatable list with the same behaviour.
///
/// We include this unit test here, to prove the problem with the .NET List type. If this test fails, we
/// can remove the SupportClass.EquatableList class, and replace it with System.Collection.Generic.List.
///
[Test]
public void System_Collections_Generic_List_Not_Suitable_For_Determining_Uniqueness_In_HashSet()
{
// reference equality
var foo = new Object();
var bar = new Object();
var list1 = new List