//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.ServiceLayer.Utility;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
{
///
/// Tests for the LongList class
///
public class LongListTests
{
///
/// Add and remove and item in a LongList
///
[Fact]
public void LongListTest()
{
var longList = new LongList();
longList.Add('.');
Assert.True(longList.Count == 1);
longList.RemoveAt(0);
Assert.True(longList.Count == 0);
}
///
/// Add and remove and item in a LongList causing an expansion
///
[Fact]
public void LongListExpandTest()
{
var longList = new LongList();
longList.ExpandListSize = 3;
for (int i = 0; i < 6; ++i)
{
longList.Add(i);
}
Assert.Equal(longList.Count, 6);
Assert.NotNull(longList.GetItem(4));
bool didEnum = false;
foreach (var j in longList)
{
didEnum = true;
break;
}
Assert.True(didEnum);
longList.RemoveAt(4);
Assert.Equal(longList.Count, 5);
}
}
}