Skip to content

Commit

Permalink
Test updates:
Browse files Browse the repository at this point in the history
- Remove FluentAssertions
- Update dependencies
  • Loading branch information
craigmccauley committed Jan 25, 2025
1 parent fd7ceb9 commit f47fad9
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 111 deletions.
8 changes: 4 additions & 4 deletions src/QueryR.Tests/JoinQueryTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentAssertions;
using QueryR.QueryModels;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System.Linq;
using Xunit;

Expand Down Expand Up @@ -37,10 +37,10 @@ on person equals pet.Owner
//assert
var (Count, Items) = result.GetCountAndList();

Count.Should().Be(3);
Count.ShouldBe(3);
foreach(var item in Items)
{
item.OwnerName.Should().Be("Craig");
item.OwnerName.ShouldBe("Craig");
}
}
}
Expand Down
52 changes: 26 additions & 26 deletions src/QueryR.Tests/QueryActions/FilterQueryActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FluentAssertions;
using QueryR.QueryActions;
using QueryR.QueryActions;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -43,8 +43,8 @@ internal void Filter_ShouldWorkAsExpected(

//assert
var (count, list) = result.GetCountAndList();
count.Should().Be(1);
list.First().Should().Be(testData.Craig);
count.ShouldBe(1);
list.First().ShouldBe(testData.Craig);
}

[Theory, AutoSubData]
Expand Down Expand Up @@ -78,8 +78,8 @@ internal void Filter_WhenItemIsOnNavigationPropertyPath_ShouldWorkAsExpected(

//assert
var (count, list) = result.GetCountAndList();
count.Should().Be(1);
list.First().Should().Be(testData.Craig);
count.ShouldBe(1);
list.First().ShouldBe(testData.Craig);
}

[Theory, AutoSubData]
Expand Down Expand Up @@ -112,8 +112,8 @@ internal void Filter_WhenNavigationPropertyPathIsCollectionChild_ShouldWorkAsExp

//assert
var (count, list) = result.GetCountAndList();
count.Should().Be(1);
list.First().Should().Be(testData.Craig);
count.ShouldBe(1);
list.First().ShouldBe(testData.Craig);
}


Expand Down Expand Up @@ -147,8 +147,8 @@ internal void Filter_WhenNavigationPropertyPathIsCollection_ShouldWorkAsExpected

//assert
var (count, list) = result.GetCountAndList();
count.Should().Be(1);
list.First().Should().Be(testData.Bob);
count.ShouldBe(1);
list.First().ShouldBe(testData.Bob);
}
[Theory, AutoSubData]
internal void Filter_WhenParentNavigationPropertyPathIsCollection_ShouldWorkAsExpected(
Expand Down Expand Up @@ -180,9 +180,9 @@ internal void Filter_WhenParentNavigationPropertyPathIsCollection_ShouldWorkAsEx

//assert
var (count, list) = result.GetCountAndList();
count.Should().Be(2);
list.Should().Contain(testData.Craig);
list.Should().Contain(testData.Bob);
count.ShouldBe(2);
list.ShouldContain(testData.Craig);
list.ShouldContain(testData.Bob);
}

[Theory, AutoSubData]
Expand Down Expand Up @@ -215,9 +215,9 @@ internal void Filter_WhenCollectionWithTypeMismatch_ShouldNotFilter(
var exception = Record.Exception(() => result = sut.Execute(query, queryResult));

//assert
exception.Should().BeNull();
exception.ShouldBeNull();
var (count, items) = result.GetCountAndList();
items.Should().BeEquivalentTo(testData.Persons);
items.ShouldBeEquivalentTo(testData.Persons);
}

[Theory, AutoSubData]
Expand Down Expand Up @@ -250,9 +250,9 @@ internal void Filter_WhenObjectWithTypeMismatch_ShouldNotFilter(
var exception = Record.Exception(() => result = sut.Execute(query, queryResult));

//assert
exception.Should().BeNull();
exception.ShouldBeNull();
var (count, items) = result.GetCountAndList();
items.Should().BeEquivalentTo(testData.Persons);
items.ShouldBeEquivalentTo(testData.Persons);
}

[Theory, AutoSubData]
Expand All @@ -266,9 +266,9 @@ internal void Filter_WhenQueryResultIsNull_ShouldThrowArgumentNullException(
var result = Record.Exception(() => sut.Execute<Person>(query, null));

//assert
var ex = result.Should().BeOfType<ArgumentNullException>().Which;
ex.ParamName.Should().Be("queryResult");
ex.Message.Should().StartWith("QueryResult cannot be null.");
var ex = result.ShouldBeOfType<ArgumentNullException>();
ex.ParamName.ShouldBe("queryResult");
ex.Message.ShouldStartWith("QueryResult cannot be null.");
}

[Theory, AutoSubData]
Expand All @@ -287,9 +287,9 @@ internal void Filter_WhenPagedQueryIsNull_ShouldThrowArgumentNullException(
var result = Record.Exception(() => sut.Execute(query, queryResult));

// Assert
var ex = result.Should().BeOfType<ArgumentNullException>().Which;
ex.ParamName.Should().Be("queryResult.PagedQuery");
ex.Message.Should().StartWith("PagedQuery within QueryResult cannot be null.");
var ex = result.ShouldBeOfType<ArgumentNullException>();
ex.ParamName.ShouldBe("queryResult.PagedQuery");
ex.Message.ShouldStartWith("PagedQuery within QueryResult cannot be null.");
}

[Theory, AutoSubData]
Expand All @@ -308,9 +308,9 @@ internal void Filter_WhenCountQueryIsNull_ShouldThrowArgumentNullException(
var result = Record.Exception(() => sut.Execute(query, queryResult));

// Assert
var ex = result.Should().BeOfType<ArgumentNullException>().Which;
ex.ParamName.Should().Be("queryResult.CountQuery");
ex.Message.Should().StartWith("CountQuery within QueryResult cannot be null.");
var ex = result.ShouldBeOfType<ArgumentNullException>();
ex.ParamName.ShouldBe("queryResult.CountQuery");
ex.Message.ShouldStartWith("CountQuery within QueryResult cannot be null.");
}
}
}
8 changes: 4 additions & 4 deletions src/QueryR.Tests/QueryActions/PagingQueryActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FluentAssertions;
using QueryR.QueryActions;
using QueryR.QueryActions;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System.Linq;
using Xunit;
using static QueryR.Tests.TestHelpers.TestData;
Expand Down Expand Up @@ -37,8 +37,8 @@ internal void Paging_ShouldWorkAsExpected(

//assert
var (count, list) = result.GetCountAndList();
count.Should().Be(2);
list.First().Should().Be(testData.Craig);
count.ShouldBe(2);
list.First().ShouldBe(testData.Craig);
}
}
}
20 changes: 10 additions & 10 deletions src/QueryR.Tests/QueryActions/SortQueryActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FluentAssertions;
using QueryR.QueryActions;
using QueryR.QueryActions;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using Xunit;
Expand Down Expand Up @@ -42,9 +42,9 @@ internal void Sort_ShouldWorkAsExpected(

//assert
var (count, list) = result.GetCountAndList();
count.Should().Be(2);
list.First().Should().Be(testData.Craig);
list.Skip(1).First().Should().Be(testData.Bob);
count.ShouldBe(2);
list.First().ShouldBe(testData.Craig);
list.Skip(1).First().ShouldBe(testData.Bob);
}

[Theory, AutoSubData]
Expand Down Expand Up @@ -81,11 +81,11 @@ internal void Sort_WhenItemIsOnNavigationPropertyPath_ShouldWorkAsExpected(
var result = sut.Execute(query, queryResult).ToList();

//assert
result[0].Should().BeSameAs(testData.Rufus);
result[1].Should().BeSameAs(testData.Titan);
result[2].Should().BeSameAs(testData.Kitty);
result[3].Should().BeSameAs(testData.Meowswers);
result[4].Should().BeSameAs(testData.Tweeter);
result[0].ShouldBeSameAs(testData.Rufus);
result[1].ShouldBeSameAs(testData.Titan);
result[2].ShouldBeSameAs(testData.Kitty);
result[3].ShouldBeSameAs(testData.Meowswers);
result[4].ShouldBeSameAs(testData.Tweeter);
}
}
}
10 changes: 5 additions & 5 deletions src/QueryR.Tests/QueryActions/SparseFieldsQueryActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using AutoFixture.Xunit2;
using FluentAssertions;
using NSubstitute;
using QueryR.QueryActions;
using QueryR.QueryModels;
using QueryR.Services;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using Xunit;
Expand Down Expand Up @@ -51,10 +51,10 @@ internal void SparseField_ShouldWorkAsExpected(

//assert
var (count, list) = result.GetCountAndList();
count.Should().Be(2);
list.First().Id.Should().Be(default);
list.First().Name.Should().Be(testData.Craig.Name);
list.First().Pets.Should().BeNull();
count.ShouldBe(2);
list.First().Id.ShouldBe(default);
list.First().Name.ShouldBe(testData.Craig.Name);
list.First().Pets.ShouldBeNull();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentAssertions;
using QueryR.QueryModels;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -25,6 +25,6 @@ public void CollectionContains_ShouldWorkOnList(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().Contain(list => list.Contains(valueToFind));
result.ShouldContain(list => list.Contains(valueToFind));
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using FluentAssertions;
using QueryR.QueryModels;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace QueryR.Tests.QueryModels.FilterOperatorsTests;
Expand All @@ -27,6 +25,6 @@ public void Contains_ShouldWorkOnString(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().OnlyContain(value => value.Contains(valueToContain));
result.ShouldAllBe(value => value.Contains(valueToContain));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentAssertions;
using QueryR.QueryModels;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -25,6 +25,6 @@ public void EndsWith_ShouldWorkOnString(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().OnlyContain(value => value.EndsWith(valueToEndWith));
result.ShouldAllBe(value => value.EndsWith(valueToEndWith));
}
}
24 changes: 12 additions & 12 deletions src/QueryR.Tests/QueryModels/FilterOperatorsTests/EqualTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentAssertions;
using QueryR.QueryModels;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -25,8 +25,8 @@ public void Equal_ShouldWorkOnValueTypes(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().HaveCount(1);
result.First().Should().Be(valueToEqual);
result.ShouldHaveSingleItem();
result.First().ShouldBe(valueToEqual);
}

[Theory, AutoSubData]
Expand All @@ -44,8 +44,8 @@ public void Equal_ShouldWorkOnString(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().HaveCount(1);
result.First().Should().Be(valueToEqual);
result.ShouldHaveSingleItem();
result.First().ShouldBe(valueToEqual);
}
[Theory, AutoSubData]
public void Equal_ShouldWorkOnGuid(
Expand All @@ -62,8 +62,8 @@ public void Equal_ShouldWorkOnGuid(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().HaveCount(1);
result.First().Should().Be(valueToEqual);
result.ShouldHaveSingleItem();
result.First().ShouldBe(valueToEqual);
}
[Theory, AutoSubData]
public void Equal_ShouldWorkOnDateTime(
Expand All @@ -80,8 +80,8 @@ public void Equal_ShouldWorkOnDateTime(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().HaveCount(1);
result.First().Should().Be(valueToEqual);
result.ShouldHaveSingleItem();
result.First().ShouldBe(valueToEqual);
}
public class TestDummy { }
[Theory, AutoSubData]
Expand All @@ -99,7 +99,7 @@ public void Equal_ShouldWorkOnReferenceType(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().HaveCount(1);
result.First().Should().Be(valueToEqual);
result.ShouldHaveSingleItem();
result.First().ShouldBe(valueToEqual);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using FluentAssertions;
using QueryR.QueryModels;
using QueryR.QueryModels;
using QueryR.Tests.TestHelpers;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace QueryR.Tests.QueryModels.FilterOperatorsTests;
Expand All @@ -27,7 +25,7 @@ public void GreaterThanOrEqual_ShouldWorkOnValueTypes(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().OnlyContain(value => value >= valueToCompare);
result.ShouldAllBe(value => value >= valueToCompare);
}

[Theory, AutoSubData]
Expand All @@ -45,6 +43,6 @@ public void GreaterThanOrEqual_ShouldWorkOnDateTime(
var result = values.AsQueryable().Where(whereExpression).ToList();

//assert
result.Should().OnlyContain(value => value >= valueToCompare);
result.ShouldAllBe(value => value >= valueToCompare);
}
}
Loading

0 comments on commit f47fad9

Please sign in to comment.