Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Fausto David committed Dec 31, 2019
1 parent 5852fa9 commit eff7202
Show file tree
Hide file tree
Showing 9 changed files with 748 additions and 743 deletions.
1 change: 1 addition & 0 deletions perf/ListPool.Benchmarks/ListPoolClearBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ListPoolClearBenchmarks

[Params(1000)]
public int N { get; set; }

[Params(0.10, 0.50, 0.80, 1)]
public double CapacityFilled { get; set; }

Expand Down
8 changes: 4 additions & 4 deletions perf/ListPool.Benchmarks/ListPoolContainsBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ namespace ListPool.Benchmarks
[GcConcurrent]
public class ListPoolContainsBenchmark
{
[Params(10, 100, 1000, 10000)]
public int N { get; set; }

private List<int> _list;
private ListPool<int> _listPool;

[Params(10, 100, 1000, 10000)]
public int N { get; set; }

[IterationSetup]
public void IterationSetup()
{
_list = new List<int>(N);
_listPool = new ListPool<int>(N);

for (int i = 1; i <= N; i++)
for (int i = 1; i <= N; i++)
{
_list.Add(i);
_listPool.Add(i);
Expand Down
8 changes: 4 additions & 4 deletions perf/ListPool.Benchmarks/ListPoolCopyToBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ namespace ListPool.Benchmarks
[GcConcurrent]
public class ListPoolCopyToBenchmarks
{
[Params(10, 100, 1000, 10000)]
public int N { get; set; }

private List<int> _list;
private ListPool<int> _listPool;
private int[] _listCopy;
private ListPool<int> _listPool;
private int[] _listPoolCopy;

[Params(10, 100, 1000, 10000)]
public int N { get; set; }

[IterationSetup]
public void IterationSetup()
{
Expand Down
6 changes: 3 additions & 3 deletions perf/ListPool.Benchmarks/ListPoolIndexOfBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace ListPool.Benchmarks
[GcConcurrent]
public class ListPoolIndexOfBenchmarks
{
[Params(10, 100, 1000, 10000)]
public int N { get; set; }

private List<int> _list;
private ListPool<int> _listPool;

[Params(10, 100, 1000, 10000)]
public int N { get; set; }

[IterationSetup]
public void IterationSetup()
{
Expand Down
6 changes: 3 additions & 3 deletions perf/ListPool.Benchmarks/ListPoolRemoveAtBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace ListPool.Benchmarks
[GcConcurrent]
public class ListPoolRemoveAtBenchmarks
{
[Params(10, 100, 1000, 10000)]
public int N { get; set; }

private List<int> _list;
private ListPool<int> _listPool;

[Params(10, 100, 1000, 10000)]
public int N { get; set; }

[IterationSetup]
public void IterationSetup()
{
Expand Down
6 changes: 3 additions & 3 deletions perf/ListPool.Benchmarks/ListPoolRemoveBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace ListPool.Benchmarks
[GcConcurrent]
public class ListPoolRemoveBenchmarks
{
[Params(10, 100, 1000, 10000)]
public int N { get; set; }

private List<int> _list;
private ListPool<int> _listPool;

[Params(10, 100, 1000, 10000)]
public int N { get; set; }

[IterationSetup]
public void IterationSetup()
{
Expand Down
1 change: 1 addition & 0 deletions tests/ListPool.UnitTests/EnumeratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void Reset_allows_enumerator_to_be_enumerate_again()
Assert.True(sut.MoveNext());
Assert.Equal(expectedEnumerator.Current, sut.Current);
}

Assert.False(sut.MoveNext());
sut.Reset();
expectedEnumerator.Reset();
Expand Down
123 changes: 62 additions & 61 deletions tests/ListPool.UnitTests/ListPoolAsIList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,55 +33,6 @@ public override void Add_items_when_capacity_is_full_then_buffer_autogrow()
Assert.True(expectedItems.All(expectedItem => sut.Contains(expectedItem)));
}

[Fact]
public void Add_item_when_is_not_same_type_throw_ArgumentException()
{
using var listPool = new ListPool<int>();
IList sut = listPool;
string itemWithWrongType = s_fixture.Create<string>();

ArgumentException actualException = Assert.Throws<ArgumentException>(() => sut.Add(itemWithWrongType));
Assert.Equal("item", actualException.ParamName);
}

[Fact]
public void Insert_item_when_is_not_same_type_throw_ArgumentException()
{
using var listPool = new ListPool<int>();
IList sut = listPool;
string itemWithWrongType = s_fixture.Create<string>();

ArgumentException actualException = Assert.Throws<ArgumentException>(() => sut.Insert(0, itemWithWrongType));
Assert.Equal("item", actualException.ParamName);
}

[Fact]
public void IsFixedSize_always_return_false()
{
using var listPool = new ListPool<int>();
IList sut = listPool;

Assert.False(sut.IsFixedSize);
}

[Fact]
public void IsSynchronized_always_return_false()
{
using var listPool = new ListPool<int>();
IList sut = listPool;

Assert.False(sut.IsSynchronized);
}

[Fact]
public void SyncRoot_never_is_null()
{
using var listPool = new ListPool<int>();
IList sut = listPool;

Assert.NotNull(sut.SyncRoot);
}

public override void Contains_empty_ListPool_without_indicating_capacity_returns_false()
{
int randomItem = s_fixture.Create<int>();
Expand Down Expand Up @@ -378,7 +329,7 @@ public override void Remove_when_item_is_null_return_false()
using var listPool = new ListPool<string>();
IList sut = listPool;

sut.Remove(item);
sut.Remove(item);
}


Expand Down Expand Up @@ -476,23 +427,33 @@ public override void Set_item_with_index_bellow_zero_throws_ArgumentOutOfRangeEx
}

[Fact]
public void Set_item_with_another_type_throws_ArgumentException()
public void Add_item_when_is_not_same_type_throw_ArgumentException()
{
const int index = 0;
using var listPool = new ListPool<int>();
IList sut = listPool;
string itemWithWrongType = s_fixture.Create<string>();
var listPool = new ListPool<int> { s_fixture.Create<int>() };

ArgumentException actualException = Assert.Throws<ArgumentException>(() => sut.Add(itemWithWrongType));
Assert.Equal("item", actualException.ParamName);
}

[Fact]
public void Contains_item_with_another_type_throws_ArgumentException()
{
string itemWithWrongType = s_fixture.Create<string>();
var listPool = new ListPool<int> {s_fixture.Create<int>()};
IList sut = listPool;

ArgumentException exception = Assert.Throws<ArgumentException>(() => sut[index] = itemWithWrongType);
ArgumentException exception = Assert.Throws<ArgumentException>(() => sut.Contains(itemWithWrongType));

Assert.Equal("value", exception.ParamName);
Assert.Equal("item", exception.ParamName);
}

[Fact]
public void IndexOf_item_with_another_type_throws_ArgumentException()
{
string itemWithWrongType = s_fixture.Create<string>();
var listPool = new ListPool<int> { s_fixture.Create<int>() };
var listPool = new ListPool<int> {s_fixture.Create<int>()};
IList sut = listPool;

ArgumentException exception = Assert.Throws<ArgumentException>(() => sut.IndexOf(itemWithWrongType));
Expand All @@ -501,27 +462,67 @@ public void IndexOf_item_with_another_type_throws_ArgumentException()
}

[Fact]
public void Contains_item_with_another_type_throws_ArgumentException()
public void Insert_item_when_is_not_same_type_throw_ArgumentException()
{
using var listPool = new ListPool<int>();
IList sut = listPool;
string itemWithWrongType = s_fixture.Create<string>();
var listPool = new ListPool<int> { s_fixture.Create<int>() };

ArgumentException actualException =
Assert.Throws<ArgumentException>(() => sut.Insert(0, itemWithWrongType));
Assert.Equal("item", actualException.ParamName);
}

[Fact]
public void IsFixedSize_always_return_false()
{
using var listPool = new ListPool<int>();
IList sut = listPool;

ArgumentException exception = Assert.Throws<ArgumentException>(() => sut.Contains(itemWithWrongType));
Assert.False(sut.IsFixedSize);
}

Assert.Equal("item", exception.ParamName);
[Fact]
public void IsSynchronized_always_return_false()
{
using var listPool = new ListPool<int>();
IList sut = listPool;

Assert.False(sut.IsSynchronized);
}

[Fact]
public void Remove_item_with_another_type_throws_ArgumentException()
{
string itemWithWrongType = s_fixture.Create<string>();
var listPool = new ListPool<int> { s_fixture.Create<int>() };
var listPool = new ListPool<int> {s_fixture.Create<int>()};
IList sut = listPool;

ArgumentException exception = Assert.Throws<ArgumentException>(() => sut.Remove(itemWithWrongType));

Assert.Equal("item", exception.ParamName);
}

[Fact]
public void Set_item_with_another_type_throws_ArgumentException()
{
const int index = 0;
string itemWithWrongType = s_fixture.Create<string>();
var listPool = new ListPool<int> {s_fixture.Create<int>()};
IList sut = listPool;

ArgumentException exception = Assert.Throws<ArgumentException>(() => sut[index] = itemWithWrongType);

Assert.Equal("value", exception.ParamName);
}

[Fact]
public void SyncRoot_never_is_null()
{
using var listPool = new ListPool<int>();
IList sut = listPool;

Assert.NotNull(sut.SyncRoot);
}
}
}
Loading

0 comments on commit eff7202

Please sign in to comment.