Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/core/Dime.Linq.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Version>1.4.0</Version>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<Version>1.5.0</Version>
<Authors>Dime Software</Authors>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -15,15 +15,15 @@
<Copyright>Copyright © 2024</Copyright>
<PackageTags>linq</PackageTags>
<NeutralLanguage>en</NeutralLanguage>
<AssemblyVersion>1.4.0.0</AssemblyVersion>
<FileVersion>1.4.0.0</FileVersion>
<AssemblyVersion>1.5.0.0</AssemblyVersion>
<FileVersion>1.5.0.0</FileVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<IncludeSource>True</IncludeSource>
<IncludeSymbols>True</IncludeSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.6.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/test/AggregateExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void AggregateExtensions_List_JoinString_DefaultSeparator_ShouldReturnCon
];

string allCustomers = customers.Aggregate(x => x.Id);
Assert.IsTrue(allCustomers == "1,2,3,4");
Assert.AreEqual("1,2,3,4", allCustomers);
}

[TestMethod]
Expand All @@ -35,7 +35,7 @@ public void AggregateExtensions_List_JoinString_CustomSeparator_ShouldReturnConc
];

string allCustomers = customers.Aggregate(x => x.Id, ". ");
Assert.IsTrue(allCustomers == "1. 2. 3. 4");
Assert.AreEqual("1. 2. 3. 4", allCustomers);
}
}
}
8 changes: 4 additions & 4 deletions src/test/Dime.Linq.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/test/DistinctExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void DistinctBy_Tuples_ShouldReturnDistinctItems()
new Tuple<int, Customer>(6, new Customer(6, "Category 2", "Address 1"))
];

Assert.IsTrue(customers.DistinctBy(x => x.Name).Count() == 3);
Assert.AreEqual(3, customers.DistinctBy(x => x.Name).Count());
}

[TestMethod]
Expand All @@ -38,7 +38,7 @@ public void DistinctBy_List_ShouldReturnDistinctItems()
new Customer(6, "Category 2", "Address 1")
];

Assert.IsTrue(customers.DistinctBy(x => x.Name).Count() == 3);
Assert.AreEqual(3, customers.DistinctBy(x => x.Name).Count());
}

[TestMethod]
Expand All @@ -54,7 +54,7 @@ public void DistinctBy_List_Filter_ShouldReturnDistinctItems()
new Customer(6, "Category 2", "Address 1")
];

Assert.IsTrue(customers.DistinctBy(x => x.Name, x => x.Id != 4).Count() == 2);
Assert.AreEqual(2, customers.DistinctBy(x => x.Name, x => x.Id != 4).Count());
}
}
}
2 changes: 1 addition & 1 deletion src/test/ExceptionHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void CatchExceptions_LoopsWithoutErrors()
];

List<Client> clients = customers.Select(x => new Client { Id = x.Id }).CatchExceptions(x => { }).ToList();
Assert.IsTrue(clients.Count() == 2);
Assert.AreEqual(2, clients.Count());
}
}
}
16 changes: 8 additions & 8 deletions src/test/FirstExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class FirstExtensionsTests
public void First_SourceIsNull_ThrowsException()
{
List<Customer> customers = null;
Assert.ThrowsException<ArgumentNullException>(() => customers.First(x => x.Id > 0, x => x.Name != "Handsome B. Wonderful"));
Assert.Throws<ArgumentNullException>(() => customers.First(x => x.Id > 0, x => x.Name != "Handsome B. Wonderful"));
}

[TestMethod]
Expand All @@ -27,7 +27,7 @@ public void First_FirstFilterPasses_ReturnsItem()
];

Customer firstCustomer = customers.First(x => x.Id > 0, x => x.Name != "Handsome B. Wonderful");
Assert.IsTrue(firstCustomer.Id == 1);
Assert.AreEqual(1, firstCustomer.Id);
}

[TestMethod]
Expand All @@ -41,7 +41,7 @@ public void First_SecondFilterPasses_ReturnsItem()
];

Customer firstCustomer = customers.First(x => x.Id > 1, x => x.Name == "Handsome B. Wonderful");
Assert.IsTrue(firstCustomer.Id == 5);
Assert.AreEqual(5, firstCustomer.Id);
}

[TestMethod]
Expand All @@ -55,15 +55,15 @@ public void First_NoFilterPasses_ReturnsDefault()
];

Customer firstCustomer = customers.First(x => x.Id > 15, x => x.Name == "Handsome B. Wonderful");
Assert.IsTrue(firstCustomer.Id == 1);
Assert.AreEqual(1, firstCustomer.Id);
}

[TestMethod]
public void FirstOrDefault_SourceIsNull_ThrowsException()
{
List<Customer> customers = null;

Assert.ThrowsException<ArgumentNullException>(() => customers.FirstOrDefault(x => x.Id > 0, x => x.Name != "Handsome B. Wonderful"));
Assert.Throws<ArgumentNullException>(() => customers.FirstOrDefault(x => x.Id > 0, x => x.Name != "Handsome B. Wonderful"));
}

[TestMethod]
Expand All @@ -77,7 +77,7 @@ public void FirstOrDefault_FirstFilterPasses_ReturnsItem()
];

Customer firstCustomer = customers.FirstOrDefault(x => x.Id > 0, x => x.Name != "Handsome B. Wonderful");
Assert.IsTrue(firstCustomer.Id == 1);
Assert.AreEqual(1, firstCustomer.Id);
}

[TestMethod]
Expand All @@ -91,7 +91,7 @@ public void FirstOrDefault_SecondFilterPasses_ReturnsItem()
];

Customer firstCustomer = customers.FirstOrDefault(x => x.Id > 1, x => x.Name == "Handsome B. Wonderful");
Assert.IsTrue(firstCustomer.Id == 5);
Assert.AreEqual(5, firstCustomer.Id);
}

[TestMethod]
Expand All @@ -105,7 +105,7 @@ public void FirstOrDefault_NoFilterPasses_ReturnsDefault()
];

Customer firstCustomer = customers.FirstOrDefault(x => x.Id > 15, x => x.Name == "Handsome B. Wonderful");
Assert.IsTrue(firstCustomer.Id == 1);
Assert.AreEqual(1, firstCustomer.Id);
}
}
}
8 changes: 4 additions & 4 deletions src/test/ForkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public void Fork_WithDataInBothSets_ShouldSplitIntoTwo_PopulatedSets()

(IEnumerable<Customer> success, IEnumerable<Customer> failed) = customers.Fork(x => x.Address == "Bumtown");

Assert.IsTrue(success.Count() == 2);
Assert.IsTrue(failed.Count() == 1);
Assert.AreEqual(2, success.Count());
Assert.AreEqual(1, failed.Count());
}

[TestMethod]
Expand All @@ -35,7 +35,7 @@ public void Fork_WithEmptyDataInOneSet_ShouldSplitIntoTwo_EmptyCollection()

(IEnumerable<Customer> success, IEnumerable<Customer> failed) = customers.Fork(x => x.Address == "Bumtown");

Assert.IsTrue(success.Count() == 2);
Assert.AreEqual(2, success.Count());
Assert.IsTrue(!failed.Any());
}

Expand All @@ -52,7 +52,7 @@ public void Fork_WithEmptyDataInBothSet_ShouldSplitIntoTwo_NoData()
(IEnumerable<Customer> success, IEnumerable<Customer> failed) = customers.Fork(x => x.Address == "Not Bumtown");

Assert.IsTrue(!success.Any());
Assert.IsTrue(failed.Count() == 3);
Assert.AreEqual(3, failed.Count());
}
}
}
16 changes: 8 additions & 8 deletions src/test/GroupExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public void GroupByMany_NoDuplicates_ShouldReturnFlatGroup()
];

List<IGrouping<object, Customer>> groups = customers.GroupByMany(x => x.Name, x => x.Address).ToList();
Assert.IsTrue(groups.Count == 5);
Assert.AreEqual(5, groups.Count);

Assert.IsTrue(
groups
Assert.AreEqual(
1, groups
.FirstOrDefault(x =>
{
object[] keys = x.Key as object[];
return (string)keys[0] == "Jeff" && (string)keys[1] == "New York";
})
.Count() == 1);
.Count());
}

[TestMethod]
Expand All @@ -46,16 +46,16 @@ public void GroupByMany_HasDuplicates_ShouldReturnNestedGroups()
];

List<IGrouping<object, Customer>> groups = customers.GroupByMany(x => x.Name, x => x.Address).ToList();
Assert.IsTrue(groups.Count == 4);
Assert.AreEqual(4, groups.Count);

Assert.IsTrue(
groups
Assert.AreEqual(
2, groups
.FirstOrDefault(x =>
{
object[] keys = x.Key as object[];
return (string)keys[0] == "Jeff" && (string)keys[1] == "New York";
})
.Count() == 2);
.Count());
}
}
}
42 changes: 21 additions & 21 deletions src/test/JoinExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public void Join_SameType_ReturnsCollectionTwoWithDataFromCollectionOne()
];

IEnumerable<Customer> mergedLists = customers1.Merge<Customer>(customers2, (x, y) => new Customer(y.Id, x.Name, x.Address));
Assert.IsTrue(mergedLists.Count() == 3);
Assert.IsTrue(mergedLists.ElementAt(0).Name == "Customer 1");
Assert.AreEqual(3, mergedLists.Count());
Assert.AreEqual("Customer 1", mergedLists.ElementAt(0).Name);
}

[TestMethod]
Expand All @@ -49,8 +49,8 @@ public void Join_SameType_ListOneHasMoreItems_ReturnsCollectionTwoWithDataFromCo
];

IEnumerable<Customer> mergedLists = customers1.Merge<Customer>(customers2, (x, y) => new Customer(y.Id, x.Name, x.Address));
Assert.IsTrue(mergedLists.Count() == 4);
Assert.IsTrue(mergedLists.ElementAt(0).Name == "Customer 1");
Assert.AreEqual(4, mergedLists.Count());
Assert.AreEqual("Customer 1", mergedLists.ElementAt(0).Name);
}

[TestMethod]
Expand All @@ -72,8 +72,8 @@ public void Join_SameType_ListTwoHasMoreItems_ReturnsCollectionTwoWithDataFromCo
];

IEnumerable<Customer> mergedLists = customers1.Merge<Customer>(customers2, (x, y) => new Customer(y.Id, x.Name, x.Address));
Assert.IsTrue(mergedLists.Count() == 4);
Assert.IsTrue(mergedLists.ElementAt(0).Name == "Customer 1");
Assert.AreEqual(4, mergedLists.Count());
Assert.AreEqual("Customer 1", mergedLists.ElementAt(0).Name);
}

[TestMethod]
Expand All @@ -94,8 +94,8 @@ public void Join_DifferentType_ReturnsCollectionTwoWithDataFromCollectionOne()
];

IEnumerable<Client> mergedLists = customers1.Merge(customers2, (x, y) => new Client(y.Id, x.Name, x.Address));
Assert.IsTrue(mergedLists.Count() == 3);
Assert.IsTrue(mergedLists.ElementAt(0).Name == "Customer 1");
Assert.AreEqual(3, mergedLists.Count());
Assert.AreEqual("Customer 1", mergedLists.ElementAt(0).Name);
}

[TestMethod]
Expand All @@ -117,8 +117,8 @@ public void Join_DifferentType_FirstListHasMoreItems_ReturnsCollectionTwoWithDat
];

IEnumerable<Client> mergedLists = customers1.Merge(customers2, (x, y) => new Client(y?.Id ?? x.Id, x?.Name ?? y.Name, x?.Address ?? y.Address));
Assert.IsTrue(mergedLists.Count() == 4);
Assert.IsTrue(mergedLists.ElementAt(0).Name == "Customer 1");
Assert.AreEqual(4, mergedLists.Count());
Assert.AreEqual("Customer 1", mergedLists.ElementAt(0).Name);
}

[TestMethod]
Expand All @@ -140,8 +140,8 @@ public void Join_DifferentType_SecondListHasMoreItems_ReturnsCollectionTwoWithDa
];

IEnumerable<Client> mergedLists = customers1.Merge(customers2, (x, y) => new Client(y?.Id ?? x.Id, x?.Name ?? y.Name, x?.Address ?? y.Address));
Assert.IsTrue(mergedLists.Count() == 4);
Assert.IsTrue(mergedLists.ElementAt(0).Name == "Customer 1");
Assert.AreEqual(4, mergedLists.Count());
Assert.AreEqual("Customer 1", mergedLists.ElementAt(0).Name);
}

[TestMethod]
Expand Down Expand Up @@ -170,8 +170,8 @@ public void FullOuterJoin()
new Client(0, "Unknown client", ""))
.ToList();

Assert.IsTrue(mergedLists.Count() == 5);
Assert.IsTrue(mergedLists.ElementAt(2).Name == "Customer 3");
Assert.AreEqual(5, mergedLists.Count());
Assert.AreEqual("Customer 3", mergedLists.ElementAt(2).Name);
}

[TestMethod]
Expand Down Expand Up @@ -201,9 +201,9 @@ public void FullOuterGroupJoin_Matches_ShouldJoin()
})
.ToList();

Assert.IsTrue(groups.Count == 2);
Assert.IsTrue(groups.ElementAt(0) == "Jose Guerrero Delgado");
Assert.IsTrue(groups.ElementAt(1) == "Karen Smith");
Assert.AreEqual(2, groups.Count);
Assert.AreEqual("Jose Guerrero Delgado", groups.ElementAt(0));
Assert.AreEqual("Karen Smith", groups.ElementAt(1));
}

[TestMethod]
Expand All @@ -229,10 +229,10 @@ public void LeftOuterJoin_ShouldJoin()
(a, b) => a.Name + " " + b.LastName)
.ToList();

Assert.IsTrue(groups.Count == 3);
Assert.IsTrue(groups.ElementAt(0) == "Jose Guerrero");
Assert.IsTrue(groups.ElementAt(1) == "Jose Delgado");
Assert.IsTrue(groups.ElementAt(2) == "Karen Smith");
Assert.AreEqual(3, groups.Count);
Assert.AreEqual("Jose Guerrero", groups.ElementAt(0));
Assert.AreEqual("Jose Delgado", groups.ElementAt(1));
Assert.AreEqual("Karen Smith", groups.ElementAt(2));
}
}
}
2 changes: 1 addition & 1 deletion src/test/PipeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Pipe()
];

string allCustomers = customers.Select(x => x.Id).Pipe(x => string.Join(",", x));
Assert.IsTrue(allCustomers == "1,2,3,4");
Assert.AreEqual("1,2,3,4", allCustomers);
}
}
}
6 changes: 3 additions & 3 deletions src/test/SelectExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static bool ParseId(Client client, out int number)
}

List<Customer> customers = null;
Assert.ThrowsException<NullReferenceException>(() => customers.SelectTry<Customer, Client, int>(x => new Client() { Id = x.Id }, ParseId).ToList());
Assert.Throws<NullReferenceException>(() => customers.SelectTry<Customer, Client, int>(x => new Client() { Id = x.Id }, ParseId).ToList());
}

[TestMethod]
Expand All @@ -39,15 +39,15 @@ static bool ParseId(Client client, out int number)
];

IEnumerable<int> identifiers = customers.SelectTry<Customer, Client, int>(x => new Client() { Id = x.Id }, ParseId);
Assert.IsTrue(identifiers.Sum() == 21);
Assert.AreEqual(21, identifiers.Sum());
}

[TestMethod]
public void ConvertTo_IntToLong_ShouldReturnNewList()
{
IEnumerable<int> integerList = new List<int> { 1, 2, 3, 4, 5 };
IEnumerable<long> longList = integerList.ConvertTo<int, long>();
Assert.IsTrue(longList.Count() == 5);
Assert.AreEqual(5, longList.Count());
}
}
}