From f156caf4d4f103878bbe704ffaee8a9e7faa61e8 Mon Sep 17 00:00:00 2001 From: David Bond Date: Mon, 25 Mar 2024 20:04:00 +0000 Subject: [PATCH] Reverted breaking commit --- .../BatchODataTests.cs | 16 +- .../DeleteODataTests.cs | 2 +- .../ErrorODataTests.cs | 20 +-- .../FindNorthwindTests.cs | 20 +-- .../FindODataTests.cs | 22 +-- .../InsertODataTests.cs | 18 +- .../LinkODataTests.cs | 4 +- .../MediaODataTests.cs | 14 +- .../SpecialTests.cs | 4 +- .../TripPinTests.cs | 126 ++++++------- .../UpdateODataTests.cs | 16 +- .../BasicApi/ClientReadOnlyTests.cs | 24 +-- .../BasicApi/ClientReadWriteTests.cs | 34 ++-- .../Core/AggregationTests.cs | 6 +- .../Core/DynamicContainerTests.cs | 2 +- .../Core/DynamicDataAggregationTests.cs | 22 +-- .../Core/ExpansionTests.cs | 82 ++++----- .../Core/KeyTests.cs | 28 +-- .../Core/ODataExpandAssociationTests.cs | 12 +- .../Core/OpenTypesTests.cs | 6 +- .../Core/PluralizerTests.cs | 14 +- .../Core/RequestWriterActionTests.cs | 4 +- .../Core/RequestWriterBatchTests.cs | 2 +- .../Core/RequestWriterTests.cs | 22 +-- .../Core/ResponseReaderV3Tests.cs | 4 +- .../Core/ResponseReaderV4Tests.cs | 4 +- .../Core/SettingsTests.cs | 18 +- .../Core/TypeCacheValueConversionTests.cs | 20 +-- .../Core/TypeConverterCacheTests.cs | 2 +- .../Core/TypedDataAggregationTests.cs | 34 ++-- .../Core/TypedExpressionsTests.cs | 167 +++++++++--------- .../Core/TypedFilterAsKeyTests.cs | 64 +++---- .../Extensions/DictionaryExtensionsTests.cs | 36 ++-- .../Extensions/TypeCacheTests.cs | 8 +- .../Extensions/TypeExtensionTests.cs | 8 +- .../Extensions/XElementExtensionsTests.cs | 8 +- .../FluentApi/BatchTests.cs | 56 +++--- .../FluentApi/BatchTypedTests.cs | 16 +- .../FluentApi/DeleteTests.cs | 8 +- .../FluentApi/DeleteTypedTests.cs | 4 +- .../FluentApi/FindDynamicTests.cs | 6 +- .../FluentApi/FindTests.cs | 74 ++++---- .../FluentApi/FindTypedTests.cs | 88 ++++----- .../FluentApi/FunctionTests.cs | 22 +-- .../FluentApi/InsertDynamicTests.cs | 4 +- .../FluentApi/InsertTests.cs | 26 +-- .../FluentApi/InsertTypedTests.cs | 22 +-- .../FluentApi/LinkTests.cs | 2 +- .../FluentApi/UpdateTests.cs | 20 +-- .../FluentApi/UpdateTypedTests.cs | 8 +- .../FluentApi/WithHeaderTests.cs | 8 +- .../Reflection/MemberAccessorTests.cs | 12 +- 52 files changed, 639 insertions(+), 630 deletions(-) diff --git a/src/Simple.OData.Client.IntegrationTests/BatchODataTests.cs b/src/Simple.OData.Client.IntegrationTests/BatchODataTests.cs index d1361e7d..69cfa544 100644 --- a/src/Simple.OData.Client.IntegrationTests/BatchODataTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/BatchODataTests.cs @@ -120,7 +120,7 @@ public async Task InsertSingleEntityWithSingleAssociationSingleBatch() .Expand(ProductCategoryName) .Filter("Name eq 'Test14'") .FindEntryAsync(); - ProductCategoryFunc(product)["ID"].Should().Be(5013); + Assert.Equal(5013, ProductCategoryFunc(product)["ID"]); } [Fact] @@ -170,7 +170,7 @@ public async Task ExecuteXCsrfFetchPriorToBatchExecution() await client.GetMetadataDocumentAsync(); // Since the token was never updated it should still be an empty string. - token.Should().NotBeNull(); + Assert.NotNull(token); // Change the settings for the client so we can re-use the session and create a new request with different headers var newHeaders = new Dictionary> @@ -213,8 +213,8 @@ public async Task IgnoreResourceNotFoundExceptionInBatchRequest() await batch.ExecuteAsync(); - bread.Should().ContainKey("ID"); - milk.Should().ContainKey("ID"); + Assert.True(bread.ContainsKey("ID")); + Assert.True(milk.ContainsKey("ID")); } [Fact] @@ -234,8 +234,8 @@ public async Task InsertWithoutResultsReadingLocationHeader() response = await x.GetResponseAsync(request); }; await batch.ExecuteAsync(); - response.Should().NotBeNull(); - response.Location.Should().Be($"{_serviceUri}Products({id})"); + Assert.NotNull(response); + Assert.Equal($"{_serviceUri}Products({id})", response.Location); } [Fact] @@ -255,7 +255,7 @@ public async Task InsertReadingLocationHeader() response = await x.GetResponseAsync(request); }; await batch.ExecuteAsync(); - response.Should().NotBeNull(); - response.Location.Should().Be($"{_serviceUri}Products({id})"); + Assert.NotNull(response); + Assert.Equal($"{_serviceUri}Products({id})", response.Location); } } diff --git a/src/Simple.OData.Client.IntegrationTests/DeleteODataTests.cs b/src/Simple.OData.Client.IntegrationTests/DeleteODataTests.cs index acdd8f3f..42884a9f 100644 --- a/src/Simple.OData.Client.IntegrationTests/DeleteODataTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/DeleteODataTests.cs @@ -90,6 +90,6 @@ await _client .Filter("Name eq 'Test1'") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } } diff --git a/src/Simple.OData.Client.IntegrationTests/ErrorODataTests.cs b/src/Simple.OData.Client.IntegrationTests/ErrorODataTests.cs index 16a95a71..60aeb1c2 100644 --- a/src/Simple.OData.Client.IntegrationTests/ErrorODataTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/ErrorODataTests.cs @@ -48,7 +48,7 @@ await _client } catch (Exception) { - true.Should().BeFalse("Expected WebRequestException"); + Assert.False(true, "Expected WebRequestException"); } } @@ -65,12 +65,12 @@ await client .Filter("NonExistingProperty eq 1") .FindEntryAsync(); - true.Should().BeFalse("Expected exception"); + Assert.False(true, "Expected exception"); } catch (WebRequestException ex) { - ex.Message.Should().NotBeNull(); - ex.Message.Should().Be(ex.ReasonPhrase); + Assert.NotNull(ex.Message); + Assert.Equal(ex.ReasonPhrase, ex.Message); } } @@ -87,12 +87,12 @@ await client .Filter("NonExistingProperty eq 1") .FindEntryAsync(); - true.Should().BeFalse("Expected exception"); + Assert.False(true, "Expected exception"); } catch (WebRequestException ex) { - ex.Message.Should().NotBeNull(); - ex.Message.Should().Be(ex.Response); + Assert.NotNull(ex.Message); + Assert.Equal(ex.Response, ex.Message); } } @@ -109,12 +109,12 @@ await client .Filter("NonExistingProperty eq 1") .FindEntryAsync(); - true.Should().BeFalse("Expected exception"); + Assert.False(true, "Expected exception"); } catch (WebRequestException ex) { - ex.Message.Should().NotBeNull(); - (ex.Message.Contains(ex.ReasonPhrase) && ex.Message.Contains(ex.Response)).Should().BeTrue(); + Assert.NotNull(ex.Message); + Assert.True(ex.Message.Contains(ex.ReasonPhrase) && ex.Message.Contains(ex.Response)); } } } diff --git a/src/Simple.OData.Client.IntegrationTests/FindNorthwindTests.cs b/src/Simple.OData.Client.IntegrationTests/FindNorthwindTests.cs index 7d4a9f01..bfc3c97b 100644 --- a/src/Simple.OData.Client.IntegrationTests/FindNorthwindTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/FindNorthwindTests.cs @@ -127,7 +127,7 @@ public async Task OrderBy() .For("Products") .OrderBy("ProductName") .FindEntriesAsync()).First(); - product["ProductName"].Should().Be("Alice Mutton"); + Assert.Equal("Alice Mutton", product["ProductName"]); } [Fact] @@ -137,8 +137,8 @@ public async Task SelectMultiple() .For("Products") .Select("ProductID", "ProductName") .FindEntryAsync(); - product.Keys.Should().Contain("ProductName"); - product.Keys.Should().Contain("ProductID"); + Assert.Contains("ProductName", product.Keys); + Assert.Contains("ProductID", product.Keys); } [Fact] @@ -149,7 +149,7 @@ public async Task ExpandOne() .OrderBy("ProductID") .Expand("Category") .FindEntriesAsync()).Last(); - (product["Category"] as IDictionary)["CategoryName"].Should().Be("Confections"); + Assert.Equal("Confections", (product["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -183,7 +183,7 @@ public async Task ExpandProductsOrderByCategoryName() .OrderBy(x => x.Category.CategoryName) .Select(x => x.Category.CategoryName) .FindEntriesAsync()).Last(); - product.Category.CategoryName.Should().Be("Condiments"); + Assert.Equal("Condiments", product.Category.CategoryName); } [Fact] @@ -196,7 +196,7 @@ public async Task ExpandCategoryOrderByProductName() .Expand(x => x.Products) .OrderBy(x => x.Products.Select(y => y.ProductName)) .FindEntriesAsync()).Last(); - category.Products.Last().ProductName.Should().Be("Röd Kaviar"); + Assert.Equal("Röd Kaviar", category.Products.Last().ProductName); } } @@ -232,7 +232,7 @@ public async Task CombineAll() .Expand("Category") .Select("Category") .FindEntriesAsync()).Single(); - (product["Category"] as IDictionary)["CategoryName"].Should().Be("Seafood"); + Assert.Equal("Seafood", (product["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -243,7 +243,7 @@ public async Task NavigateToSingle() .Key(new Entry() { { "ProductID", 2 } }) .NavigateTo("Category") .FindEntryAsync(); - category["CategoryName"].Should().Be("Beverages"); + Assert.Equal("Beverages", category["CategoryName"]); } [Fact] @@ -268,7 +268,7 @@ public async Task NavigateToRecursive() .NavigateTo("Employees1") .Key(5) .FindEntryAsync(); - employee["FirstName"].Should().Be("Steven"); + Assert.Equal("Steven", employee["FirstName"]); } [Fact] @@ -280,6 +280,6 @@ public async Task NavigateToRecursiveSingleClause() .NavigateTo("Employee1/Employee1/Employees1") .Key(5) .FindEntryAsync(); - employee["FirstName"].Should().Be("Steven"); + Assert.Equal("Steven", employee["FirstName"]); } } diff --git a/src/Simple.OData.Client.IntegrationTests/FindODataTests.cs b/src/Simple.OData.Client.IntegrationTests/FindODataTests.cs index 9518c391..078d1818 100644 --- a/src/Simple.OData.Client.IntegrationTests/FindODataTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/FindODataTests.cs @@ -79,7 +79,7 @@ public async Task OrderBy() .For("Products") .OrderBy("Name") .FindEntriesAsync()).First(); - product["Name"].Should().Be("Bread"); + Assert.Equal("Bread", product["Name"]); } [Fact] @@ -89,12 +89,12 @@ public async Task OrderByNestedComplex() .For("Suppliers") .OrderBy("Address/City") .FindEntriesAsync()).First(); - supplier["Name"].Should().Be("Tokyo Traders"); + Assert.Equal("Tokyo Traders", supplier["Name"]); supplier = (await _client .For("Suppliers") .OrderByDescending("Address/City") .FindEntriesAsync()).First(); - supplier["Name"].Should().Be("Exotic Liquids"); + Assert.Equal("Exotic Liquids", supplier["Name"]); } [Fact] @@ -104,8 +104,8 @@ public async Task SelectMultiple() .For("Products") .Select("ID", "Name") .FindEntryAsync(); - product.Keys.Should().Contain("Name"); - product.Keys.Should().Contain("ID"); + Assert.Contains("Name", product.Keys); + Assert.Contains("ID", product.Keys); } [Fact] @@ -116,7 +116,7 @@ public async Task ExpandOne() .OrderBy("ID") .Expand(ProductCategoryName) .FindEntriesAsync()).Last(); - ProductCategoryFunc(product)["Name"].Should().Be(ExpectedCategory); + Assert.Equal(ExpectedCategory, ProductCategoryFunc(product)["Name"]); } [Fact] @@ -173,7 +173,7 @@ public async Task CombineAll() .Expand(ProductCategoryName) .Select(ProductCategoryName) .FindEntriesAsync()).Single(); - ProductCategoryFunc(product)["Name"].Should().Be(ExpectedCategory); + Assert.Equal(ExpectedCategory, ProductCategoryFunc(product)["Name"]); } [Fact] @@ -184,7 +184,7 @@ public async Task NavigateToSingle() .Key(new Dictionary() { { "ID", 2 } }) .NavigateTo(ProductCategoryName) .FindEntryAsync(); - category["Name"].Should().Be("Beverages"); + Assert.Equal("Beverages", category["Name"]); } [Fact] @@ -216,7 +216,7 @@ public async Task GetMediaStream() .Media() .GetStreamAsync(); var text = Utils.StreamToString(stream); - text.Should().StartWith("Test stream data"); + Assert.StartsWith("Test stream data", text); } [Fact] @@ -234,7 +234,7 @@ public async Task GetNamedMediaStream() .Media("Photo") .GetStreamAsync(); var text = Utils.StreamToString(stream); - text.Should().StartWith("Test named stream data"); + Assert.StartsWith("Test named stream data", text); } private class PersonDetail @@ -256,6 +256,6 @@ public async Task GetTypedNamedMediaStream() .NavigateTo() .Media(x => x.Photo) .GetStreamAsStringAsync(); - text.Should().StartWith("Test named stream data"); + Assert.StartsWith("Test named stream data", text); } } diff --git a/src/Simple.OData.Client.IntegrationTests/InsertODataTests.cs b/src/Simple.OData.Client.IntegrationTests/InsertODataTests.cs index 016b096c..1ab195cf 100644 --- a/src/Simple.OData.Client.IntegrationTests/InsertODataTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/InsertODataTests.cs @@ -51,7 +51,7 @@ public async Task InsertLookupByID() .InsertEntryAsync(); ((int)product["ID"] > 0).Should().BeTrue(); - product["Name"].Should().Be("Test1"); + Assert.Equal("Test1", product["Name"]); } [Fact] @@ -70,7 +70,7 @@ public async Task InsertExpando() .Set(expando) .InsertEntryAsync()); - ((int)product["ID"] > 0).Should().BeTrue(); + Assert.True((int)product["ID"] > 0); } [Fact] @@ -85,14 +85,14 @@ public async Task InsertProductWithCategory() .Set(CreateProduct(1007, "Test6", category)) .InsertEntryAsync(); - product["Name"].Should().Be("Test6"); + Assert.Equal("Test6", product["Name"]); product = await _client .For("Products") .Filter("Name eq 'Test6'") .Expand(ProductCategoryName) .FindEntryAsync(); - product[ProductCategoryName].Should().NotBeNull(); - ProductCategoryFunc(product)["ID"].Should().Be(category["ID"]); + Assert.NotNull(product[ProductCategoryName]); + Assert.Equal(category["ID"], ProductCategoryFunc(product)["ID"]); } [Fact] @@ -105,8 +105,8 @@ public async Task InsertReadingLocationHeader() .BuildRequestFor() .InsertEntryAsync(); var response = await _client.GetResponseAsync(withRequest.GetRequest()); - response.Should().NotBeNull(); - response.Location.Should().Be($"{_serviceUri}Products({id})"); + Assert.NotNull(response); + Assert.Equal($"{_serviceUri}Products({id})", response.Location); } [Fact] @@ -119,7 +119,7 @@ public async Task InsertWithoutResultsReadingLocationHeader() .BuildRequestFor() .InsertEntryAsync(false); var response = await _client.GetResponseAsync(withRequest.GetRequest()); - response.Should().NotBeNull(); - response.Location.Should().Be($"{_serviceUri}Products({id})"); + Assert.NotNull(response); + Assert.Equal($"{_serviceUri}Products({id})", response.Location); } } diff --git a/src/Simple.OData.Client.IntegrationTests/LinkODataTests.cs b/src/Simple.OData.Client.IntegrationTests/LinkODataTests.cs index e0acfc8c..838c7292 100644 --- a/src/Simple.OData.Client.IntegrationTests/LinkODataTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/LinkODataTests.cs @@ -81,11 +81,11 @@ await _client .FindEntryAsync(); if (ProductCategoryName == "Categories") { - (product[ProductCategoryName] as IEnumerable).Should().BeEmpty(); + Assert.Empty(product[ProductCategoryName] as IEnumerable); } else { - product[ProductCategoryName].Should().BeNull(); + Assert.Null(product[ProductCategoryName]); } } } diff --git a/src/Simple.OData.Client.IntegrationTests/MediaODataTests.cs b/src/Simple.OData.Client.IntegrationTests/MediaODataTests.cs index 2ef2c851..2d72cde4 100644 --- a/src/Simple.OData.Client.IntegrationTests/MediaODataTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/MediaODataTests.cs @@ -74,7 +74,7 @@ public async Task GetTypedNamedMediaStream() .NavigateTo() .Media(x => x.Photo) .GetStreamAsStringAsync(); - text.Should().Contain("named stream data"); + Assert.Contains("named stream data", text); } [Fact] @@ -90,9 +90,9 @@ public async Task FindEntryWithEntityMedia() .WithMedia("Media") .Key(id) .FindEntryAsync(); - ad["Media"].Should().NotBeNull(); + Assert.NotNull(ad["Media"]); var text = Utils.StreamToString(ad["Media"] as Stream); - text.Should().Contain("stream data"); + Assert.Contains("stream data", text); } [Fact] @@ -104,9 +104,9 @@ public async Task FindEntryWithNamedMedia() .NavigateTo("PersonDetail") .WithMedia("Photo") .FindEntryAsync(); - person["Photo"].Should().NotBeNull(); + Assert.NotNull(person["Photo"]); var text = Utils.StreamToString(person["Photo"] as Stream); - text.Should().Contain("named stream data"); + Assert.Contains("named stream data", text); } [Fact] @@ -128,7 +128,7 @@ await _client .Media() .GetStreamAsync(); var text = Utils.StreamToString(stream); - text.Should().Be("Updated stream data"); + Assert.Equal("Updated stream data", text); } [Fact] @@ -148,6 +148,6 @@ await _client .Media("Photo") .GetStreamAsync(); var text = Utils.StreamToString(stream); - text.Should().Be("Updated named stream data"); + Assert.Equal("Updated named stream data", text); } } diff --git a/src/Simple.OData.Client.IntegrationTests/SpecialTests.cs b/src/Simple.OData.Client.IntegrationTests/SpecialTests.cs index 3a22855f..45193991 100644 --- a/src/Simple.OData.Client.IntegrationTests/SpecialTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/SpecialTests.cs @@ -217,8 +217,8 @@ public async Task MetadataErrorIsNotCached() wasCached = false; return null; }); - wasCached.Should().BeFalse(); - cached.Should().BeNull(); + Assert.False(wasCached); + Assert.Null(cached); } [Fact] diff --git a/src/Simple.OData.Client.IntegrationTests/TripPinTests.cs b/src/Simple.OData.Client.IntegrationTests/TripPinTests.cs index 8c007246..549fda49 100644 --- a/src/Simple.OData.Client.IntegrationTests/TripPinTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/TripPinTests.cs @@ -82,8 +82,8 @@ public async Task FindAllPeople() foreach (var person in people) { person.Annotations.Id.Should().NotBeNull(); - person.Annotations.ReadLink.Should().NotBeNull(); - person.Annotations.EditLink.Should().NotBeNull(); + Assert.NotNull(person.Annotations.ReadLink); + Assert.NotNull(person.Annotations.EditLink); } } @@ -101,7 +101,7 @@ public async Task FindSinglePersonWithFeedAnnotations() .FindEntriesAsync(annotations); Assert.Single(people); - annotations.NextPageLink.Should().BeNull(); + Assert.Null(annotations.NextPageLink); } [Fact] @@ -114,7 +114,7 @@ public async Task FindSinglePersonExternalHttpClient() .Key("russellwhyte") .FindEntryAsync(); - person.UserName.Should().Be("russellwhyte"); + Assert.Equal("russellwhyte", person.UserName); } [Fact] @@ -125,7 +125,7 @@ public async Task FindPeopleByGender() .Filter(x => x.Gender == (int)PersonGender.Male) .FindEntriesAsync(); - people.All(x => x.Gender == PersonGender.Male).Should().BeTrue(); + Assert.True(people.All(x => x.Gender == PersonGender.Male)); } [Fact] @@ -141,7 +141,7 @@ public async Task FindSinglePersonWithEntryAnnotations() .Filter(x => x.UserName == "russellwhyte") .FindEntryAsync(); - person.Annotations.Id.Should().NotBeNull(); + Assert.NotNull(person.Annotations.Id); } [Fact] @@ -164,9 +164,9 @@ public async Task FindPersonExpandEmptyTrips() .Key("keithpinckney") .Expand(x => new { x.Trips }) .FindEntryAsync(); - person.Trips.Should().BeEmpty(); - person.Friends.Should().BeNull(); - person.Photo.Should().BeNull(); + Assert.Empty(person.Trips); + Assert.Null(person.Friends); + Assert.Null(person.Photo); } [Fact] @@ -179,8 +179,8 @@ public async Task FindPersonExpandAndSelectTripsAndFriendsTyped() .Select(x => x.Trips.Select(y => y.Name)) .Select(x => x.Friends.Select(y => y.LastName)) .FindEntryAsync(); - person.Trips.First().Name.Should().Be("Trip in US"); - person.Friends.First().LastName.Should().Be("Ketchum"); + Assert.Equal("Trip in US", person.Trips.First().Name); + Assert.Equal("Ketchum", person.Friends.First().LastName); } [Fact] @@ -244,7 +244,7 @@ public async Task FindPersonWithDataContract() .For() .Key("russellwhyte") .FindEntryAsync(); - person.UserName.Should().Be("russellwhyte"); + Assert.Equal("russellwhyte", person.UserName); } [Fact] @@ -272,7 +272,7 @@ public async Task FindPersonPlanItemsByDate() .NavigateTo(x => x.PlanItems) .Filter(x => x.StartsAt == now) .FindEntriesAsync(); - flights.Should().BeEmpty(); + Assert.Empty(flights); } [Fact] @@ -283,7 +283,7 @@ public async Task FindPersonTwoLevelExpand() .Key("russellwhyte") .Expand(x => x.Friends.Select(y => y.Friends)) .FindEntryAsync(); - person.Should().NotBeNull(); + Assert.NotNull(person); Assert.Equal(4, person.Friends.Count()); } @@ -295,7 +295,7 @@ public async Task FindPersonThreeLevelExpand() .Key("russellwhyte") .Expand(x => x.Friends.Select(y => y.Friends.Select(z => z.Friends))) .FindEntryAsync(); - person.Should().NotBeNull(); + Assert.NotNull(person); Assert.Equal(4, person.Friends.Count()); Assert.Equal(8, person.Friends.SelectMany(x => x.Friends).Count()); } @@ -309,7 +309,7 @@ public async Task FindPersonWithAnyTrips() .Any(y => y.Budget > 10000d)) .Expand(x => x.Trips) .FindEntriesAsync(); - flights.All(x => x.Trips.Any(y => y.Budget > 10000d)).Should().BeTrue(); + Assert.True(flights.All(x => x.Trips.Any(y => y.Budget > 10000d))); Assert.Equal(2, flights.SelectMany(x => x.Trips).Count()); } @@ -322,7 +322,7 @@ public async Task FindPersonWithAllTrips() .All(y => y.Budget > 10000d)) .Expand(x => x.Trips) .FindEntriesAsync(); - flights.All(x => x.Trips is null || x.Trips.All(y => y.Budget > 10000d)).Should().BeTrue(); + Assert.True(flights.All(x => x.Trips is null || x.Trips.All(y => y.Budget > 10000d))); } [Fact] @@ -350,7 +350,7 @@ public async Task FindPersonFlight() .Key(21) .As() .FindEntryAsync(); - flight.FlightNumber.Should().Be("FM1930"); + Assert.Equal("FM1930", flight.FlightNumber); } [Fact] @@ -367,10 +367,10 @@ public async Task FindPersonFlightExpandAndSelect() .Expand(x => x.Airline) .Select(x => new { x.FlightNumber, x.Airline.AirlineCode }) .FindEntryAsync(); - flight.From.Should().BeNull(); - flight.To.Should().BeNull(); - flight.Airline.Name.Should().BeNull(); - flight.Airline.AirlineCode.Should().Be("FM"); + Assert.Null(flight.From); + Assert.Null(flight.To); + Assert.Null(flight.Airline.Name); + Assert.Equal("FM", flight.Airline.AirlineCode); } [Fact] @@ -385,7 +385,7 @@ public async Task FindPersonFlights() .As() .FindEntriesAsync(); Assert.Equal(2, flights.Count()); - (x => x.FlightNumber == "FM1930").Should().Contain(flights); + Assert.Contains(flights, x => x.FlightNumber == "FM1930"); } [Fact] @@ -398,7 +398,7 @@ public async Task FindPersonExpandPhotoWithSelect() .Top(1) .FindEntriesAsync(); var person = Assert.Single(persons); - person.Photo.Media.Should().BeNull(); + Assert.Null(person.Photo.Media); Assert.Equal(default, person.Photo.Id); } @@ -412,8 +412,8 @@ public async Task FindPersonExpandFriendsWithSelect() .Top(1) .FindEntriesAsync(); var person = Assert.Single(persons); - (x => x.UserName is null).Should().NotContain(person.Friends); - person.Friends.All(x => x.FirstName is null).Should().BeTrue(); + Assert.DoesNotContain(person.Friends, x => x.UserName is null); + Assert.True(person.Friends.All(x => x.FirstName is null)); } [Fact] @@ -429,7 +429,7 @@ public async Task FindPersonFlightsWithFilter() .Filter(x => x.FlightNumber == "FM1930") .FindEntriesAsync(); Assert.Single(flights); - flights.All(x => x.FlightNumber == "FM1930").Should().BeTrue(); + Assert.True(flights.All(x => x.FlightNumber == "FM1930")); } [Fact] @@ -476,7 +476,7 @@ public async Task UpdatePersonLastName() .Filter(x => x.UserName == "russellwhyte") .Set(new { LastName = "White" }) .UpdateEntryAsync(); - person.LastName.Should().Be("White"); + Assert.Equal("White", person.LastName); } [Fact] @@ -487,7 +487,7 @@ public async Task UpdatePersonEmail() .Filter(x => x.UserName == "russellwhyte") .Set(new { Emails = new[] { "russell.whyte@gmail.com" } }) .UpdateEntryAsync(); - person.Emails.First().Should().Be("russell.whyte@gmail.com"); + Assert.Equal("russell.whyte@gmail.com", person.Emails.First()); } [Fact] @@ -513,7 +513,7 @@ public async Task UpdatePersonAddress() }, }) .UpdateEntryAsync(); - person.AddressInfo.First().City.Name.Should().Be("Boise"); + Assert.Equal("Boise", person.AddressInfo.First().City.Name); } [Fact] @@ -534,7 +534,7 @@ public async Task InsertPersonWithTypedOpenProperty() .For("Person") .Key("gregorsamsa") .FindEntryAsync(); - person.OpenTypeString.Should().Be(@"Description"); + Assert.Equal(@"Description", person.OpenTypeString); } [Fact] @@ -557,7 +557,7 @@ public async Task InsertPersonWithDynamicOpenProperty() .WithProperties(x => x.Properties) .Key("gregorsamsa") .FindEntryAsync(); - person.Properties["OpenTypeString"].Should().Be(@"Description"); + Assert.Equal(@"Description", person.Properties["OpenTypeString"]); } [Fact] @@ -589,8 +589,8 @@ await _client .WithProperties(x => x.Properties) .Key("gregorsamsa") .FindEntryAsync(); - person.Properties["OpenTypeString"].Should().Be(@"New description"); - person.LastName.Should().Be("Samsa"); + Assert.Equal(@"New description", person.Properties["OpenTypeString"]); + Assert.Equal("Samsa", person.LastName); } [Fact] @@ -611,7 +611,7 @@ public async Task FlterPersonOnTypedOpenProperty() .For("Person") .Filter(x => x.OpenTypeString == "Description") .FindEntryAsync(); - person.OpenTypeString.Should().Be(@"Description"); + Assert.Equal(@"Description", person.OpenTypeString); } [Fact] @@ -634,7 +634,7 @@ public async Task FlterPersonOnDynamicOpenProperty() .WithProperties(x => x.Properties) .Filter(x => x.Properties["OpenTypeString"].ToString() == "Description") .FindEntryAsync(); - person.Properties["OpenTypeString"].Should().Be(@"Description"); + Assert.Equal(@"Description", person.Properties["OpenTypeString"]); } [Fact(Skip = "Fails at server")] @@ -660,7 +660,7 @@ public async Task InsertPersonWithLinkToPeople() .Key("gregorsamsa") .FindEntryAsync(); - person.Should().NotBeNull(); + Assert.NotNull(person); } [Fact(Skip = "Fails at server")] @@ -685,7 +685,7 @@ public async Task InsertPersonWithLinkToMe() .Key("gregorsamsa") .FindEntryAsync(); - person.Should().NotBeNull(); + Assert.NotNull(person); } [Fact] @@ -706,7 +706,7 @@ public async Task FilterPersonByOpenTypeProperty() .For("Person") .Filter(x => x.OpenTypeString == "Description") .FindEntryAsync(); - person.OpenTypeString.Should().Be(@"Description"); + Assert.Equal(@"Description", person.OpenTypeString); } [Fact] @@ -728,7 +728,7 @@ public async Task SelectOpenTypeStringProperty() .Key("gregorsamsa") .Select(x => new { x.UserName, x.OpenTypeString }) .FindEntryAsync(); - person.OpenTypeString.Should().Be(@"\""Description\"""); + Assert.Equal(@"\""Description\""", person.OpenTypeString); } [Fact] @@ -759,9 +759,9 @@ public async Task FindMe() var person = await _client .For("Me") .FindEntryAsync(); - person.UserName.Should().Be("aprilcline"); + Assert.Equal("aprilcline", person.UserName); Assert.Equal(2, person.Emails.Length); - person.AddressInfo.Single().City.Name.Should().Be("Lander"); + Assert.Equal("Lander", person.AddressInfo.Single().City.Name); Assert.Equal(PersonGender.Female, person.Gender); } @@ -772,9 +772,9 @@ public async Task FindMeSelectAddressInfo() .For("Me") .Select(x => x.AddressInfo) .FindEntryAsync(); - person.AddressInfo.Single().City.Name.Should().Be("Lander"); - person.UserName.Should().BeNull(); - person.Emails.Should().BeNull(); + Assert.Equal("Lander", person.AddressInfo.Single().City.Name); + Assert.Null(person.UserName); + Assert.Null(person.Emails); } [Fact] @@ -824,8 +824,8 @@ public async Task FindAirportByCode() .For() .Key("KSFO") .FindEntryAsync(); - airport.IataCode.Should().Be("SFO"); - airport.Location.City.Name.Should().Be("San Francisco"); + Assert.Equal("SFO", airport.IataCode); + Assert.Equal("San Francisco", airport.Location.City.Name); Assert.Equal(4326, airport.Location.Loc.CoordinateSystem.EpsgId); Assert.Equal(37.6188888888889, airport.Location.Loc.Latitude); Assert.Equal(-122.374722222222, airport.Location.Loc.Longitude); @@ -841,7 +841,7 @@ public async Task FindAirportOrderedByLocationAddress() .FindEntriesAsync(); var first = airports.Select(x => x.Location.Address).First(); var second = airports.Select(x => x.Location.Address).Last(); - (first.CompareTo(second) < 0).Should().BeTrue(); + Assert.True(first.CompareTo(second) < 0); airports = await _client .For() .OrderByDescending(x => x.Location.Address) @@ -849,7 +849,7 @@ public async Task FindAirportOrderedByLocationAddress() .FindEntriesAsync(); first = airports.Select(x => x.Location.Address).First(); second = airports.Select(x => x.Location.Address).Last(); - (first.CompareTo(second) > 0).Should().BeTrue(); + Assert.True(first.CompareTo(second) > 0); } [Fact] @@ -862,7 +862,7 @@ public async Task FindAirportOrderedByLocationCityName() .FindEntriesAsync(); var first = airports.Select(x => x.Location.City.Name).First(); var second = airports.Select(x => x.Location.City.Name).Last(); - (first.CompareTo(second) < 0).Should().BeTrue(); + Assert.True(first.CompareTo(second) < 0); airports = await _client .For() .OrderByDescending(x => x.Location.City.Name) @@ -870,7 +870,7 @@ public async Task FindAirportOrderedByLocationCityName() .FindEntriesAsync(); first = airports.Select(x => x.Location.City.Name).First(); second = airports.Select(x => x.Location.City.Name).Last(); - (first.CompareTo(second) > 0).Should().BeTrue(); + Assert.True(first.CompareTo(second) > 0); } [Fact] @@ -880,7 +880,7 @@ public async Task FindAirportByLocationCityRegionEquals() .For() .Filter(x => x.Location.City.Region == "California") .FindEntryAsync(); - airport.IataCode.Should().Be("SFO"); + Assert.Equal("SFO", airport.IataCode); } [Fact] @@ -890,7 +890,7 @@ public async Task FindAirportByLocationCityRegionContains() .For() .Filter(x => x.Location.City.Region.Contains("California")) .FindEntryAsync(); - airport.IataCode.Should().Be("SFO"); + Assert.Equal("SFO", airport.IataCode); } [Fact] @@ -912,7 +912,7 @@ public async Task InsertEvent() .Key(tripEvent.PlanItemId) .FindEntryAsync(); - tripEvent.Should().NotBeNull(); + Assert.NotNull(tripEvent); } [Fact] @@ -935,7 +935,7 @@ public async Task UpdateEvent() .Set(new { Description = "This is a new description" }) .UpdateEntryAsync(); - tripEvent.Description.Should().Be("This is a new description"); + Assert.Equal("This is a new description", tripEvent.Description); } [Fact] @@ -961,7 +961,7 @@ await command .Key(tripEvent.PlanItemId) .FindEntryAsync(); - tripEvent.Should().BeNull(); + Assert.Null(tripEvent); } [Fact] @@ -999,7 +999,7 @@ public async Task FindPersonTripsFilterDescription() .FindEntriesAsync(); Assert.Single(trips); - trips.Single().Description.Should().Contain("New York"); + Assert.Contains("New York", trips.Single().Description); } [Fact] @@ -1011,7 +1011,7 @@ public async Task GetNearestAirport() .Set(new { lat = 100d, lon = 100d }) .ExecuteAsSingleAsync(); - airport.IcaoCode.Should().Be("KSEA"); + Assert.Equal("KSEA", airport.IcaoCode); } [Fact] @@ -1038,7 +1038,7 @@ await _client .Filter(x => x.PlanItemId == tripEvent.PlanItemId) .FindEntryAsync(); - tripEvent.Should().BeNull(); + Assert.Null(tripEvent); } [Fact] @@ -1090,7 +1090,7 @@ public async Task GetInvolvedPeopleEmptyResult() .Key(1) .Function("GetInvolvedPeople") .ExecuteAsEnumerableAsync(); - people.Should().BeEmpty(); + Assert.Empty(people); } [Fact] @@ -1236,7 +1236,7 @@ public async Task FindEventWithNonNullStartTime() .Filter(x => x.StartsAt < DateTimeOffset.UtcNow) .FindEntryAsync(); - tripEvent.Should().NotBeNull(); + Assert.NotNull(tripEvent); } [Fact] @@ -1252,7 +1252,7 @@ public async Task FindEventWithNullStartTime() .Filter(x => x.StartsAt == null) .FindEntryAsync(); - tripEvent.Should().BeNull(); + Assert.Null(tripEvent); } [Fact] @@ -1264,7 +1264,7 @@ public async Task GetFavoriteAirline() .Function("GetFavoriteAirline") .ExecuteAsArrayAsync(); - airport.First().AirlineCode.Should().Be("AA"); + Assert.Equal("AA", airport.First().AirlineCode); } [Fact] diff --git a/src/Simple.OData.Client.IntegrationTests/UpdateODataTests.cs b/src/Simple.OData.Client.IntegrationTests/UpdateODataTests.cs index 289a59fe..d6d539d4 100644 --- a/src/Simple.OData.Client.IntegrationTests/UpdateODataTests.cs +++ b/src/Simple.OData.Client.IntegrationTests/UpdateODataTests.cs @@ -91,7 +91,7 @@ public async Task UpdateMultipleWithResult() .Set(new { Price = 123 }) .UpdateEntriesAsync()).Single(); - product["Price"].Should().Be(123d); + Assert.Equal(123d, product["Price"]); } [Fact] @@ -113,7 +113,7 @@ await _client .Key(product["ID"]) .FindEntryAsync(); - product["Price"].Should().Be(456d); + Assert.Equal(456d, product["Price"]); } [Fact] @@ -137,7 +137,7 @@ await _client .Key(product["ID"]) .FindEntryAsync(); - DateTime.Parse(product["ReleaseDate"].ToString()).Date.Should().Be(tomorrow.Date); + Assert.Equal(tomorrow.Date, DateTime.Parse(product["ReleaseDate"].ToString()).Date); } [Fact] @@ -163,7 +163,7 @@ await _client .Key(product["ID"]) .Expand(ProductCategoryName) .FindEntryAsync(); - ProductCategoryFunc(product)["ID"].Should().Be(category["ID"]); + Assert.Equal(category["ID"], ProductCategoryFunc(product)["ID"]); } [Fact] @@ -193,7 +193,7 @@ await _client .Key(product["ID"]) .Expand(ProductCategoryName) .FindEntryAsync(); - ProductCategoryFunc(product)["ID"].Should().Be(category2["ID"]); + Assert.Equal(category2["ID"], ProductCategoryFunc(product)["ID"]); } [Fact] @@ -223,7 +223,7 @@ await _client .Key(product["ID"]) .Expand(ProductCategoryName) .FindEntryAsync(); - ProductCategoryFunc(product)["ID"].Should().Be(category2["ID"]); + Assert.Equal(category2["ID"], ProductCategoryFunc(product)["ID"]); //@robertmclaws: At this point, we've verified entries and associations are available. // Now, we're going grab another copy to edit, make changes, and verify the removal was ignored with no side effects. @@ -250,8 +250,8 @@ await _client2 .Key(product["ID"]) .Expand(ProductCategoryName) .FindEntryAsync(); - ProductCategoryFunc(product)["ID"].Should().Be(ProductCategoryFunc(product2)["ID"]); - product2["Name"].Should().Be("Test99"); + Assert.Equal(ProductCategoryFunc(product2)["ID"], ProductCategoryFunc(product)["ID"]); + Assert.Equal("Test99", product2["Name"]); } // Not supported for one-to-many relationships diff --git a/src/Simple.OData.Client.UnitTests/BasicApi/ClientReadOnlyTests.cs b/src/Simple.OData.Client.UnitTests/BasicApi/ClientReadOnlyTests.cs index 19fd1828..3bda72ef 100644 --- a/src/Simple.OData.Client.UnitTests/BasicApi/ClientReadOnlyTests.cs +++ b/src/Simple.OData.Client.UnitTests/BasicApi/ClientReadOnlyTests.cs @@ -34,7 +34,7 @@ public async Task FindEntriesSelect() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var products = await client.FindEntriesAsync("Products?$select=ProductName"); Assert.Equal(1, products.First().Count); - products.First().First().Key.Should().Be("ProductName"); + Assert.Equal("ProductName", products.First().First().Key); } [Fact] @@ -58,7 +58,7 @@ public async Task FindEntry() { var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Chai'"); - product["ProductName"].Should().Be("Chai"); + Assert.Equal("Chai", product["ProductName"]); } [Fact] @@ -66,7 +66,7 @@ public async Task GetEntryExisting() { var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var product = await client.GetEntryAsync("Products", new Entry() { { "ProductID", 1 } }); - product["ProductName"].Should().Be("Chai"); + Assert.Equal("Chai", product["ProductName"]); } [Fact] @@ -74,7 +74,7 @@ public async Task GetEntryExistingCompoundKey() { var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var orderDetail = await client.GetEntryAsync("Order_Details", new Entry() { { "OrderID", 10248 }, { "ProductID", 11 } }); - orderDetail["ProductID"].Should().Be(11); + Assert.Equal(11, orderDetail["ProductID"]); } [Fact] @@ -90,7 +90,7 @@ public async Task GetEntryNonExistingIgnoreException() var client = new ODataClient(CreateDefaultSettings().WithIgnoredResourceNotFoundException().WithHttpMock()); var product = await client.GetEntryAsync("Products", new Entry() { { "ProductID", -1 } }); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -115,7 +115,7 @@ public async Task ExecuteScalarFunctionWithDateTimeParameter() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var dateTime = new DateTime(2013, 1, 1, 12, 13, 14, 789, DateTimeKind.Utc); var result = await client.ExecuteFunctionAsScalarAsync("PassThroughDateTime", new Entry() { { "dateTime", dateTime } }); - result.Should().Be(dateTime.ToUniversalTime()); + Assert.Equal(dateTime.ToUniversalTime(), result); } [Fact] @@ -134,7 +134,7 @@ public async Task FindEntryExistingDynamicFilter() var x = ODataDynamic.Expression; var filter = await ((Task)client.GetCommandTextAsync("Products", x.ProductName == "Chai")); var product = await client.FindEntryAsync(filter); - product["ProductName"].Should().Be("Chai"); + Assert.Equal("Chai", product["ProductName"]); } [Fact] @@ -144,7 +144,7 @@ public async Task FindBaseClassEntryDynamicFilter() var x = ODataDynamic.Expression; var filter = await ((Task)client.GetCommandTextAsync("Transport", x.TransportID == 1)); var ship = await client.FindEntryAsync(filter); - ship["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", ship["ShipName"]); } [Fact] @@ -154,7 +154,7 @@ public async Task FindDerivedClassEntryDynamicFilter() var x = ODataDynamic.Expression; var filter = await ((Task)client.GetCommandTextAsync("Transport/Ships", x.ShipName == "Titanic")); var ship = await client.FindEntryAsync(filter); - ship["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", ship["ShipName"]); } [Fact] @@ -163,7 +163,7 @@ public async Task FindEntryExistingTypedFilter() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var filter = await client.GetCommandTextAsync("Products", x => x.ProductName == "Chai"); var product = await client.FindEntryAsync(filter); - product["ProductName"].Should().Be("Chai"); + Assert.Equal("Chai", product["ProductName"]); } [Fact] @@ -172,7 +172,7 @@ public async Task FindBaseClassEntryTypedFilter() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var filter = await client.GetCommandTextAsync("Transport", x => x.TransportID == 1); var ship = await client.FindEntryAsync(filter); - ship["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", ship["ShipName"]); } [Fact] @@ -181,6 +181,6 @@ public async Task FindDerivedClassEntryTypedFilter() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var filter = await client.GetCommandTextAsync("Transport/Ships", x => x.ShipName == "Titanic"); var ship = await client.FindEntryAsync(filter); - ship["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", ship["ShipName"]); } } diff --git a/src/Simple.OData.Client.UnitTests/BasicApi/ClientReadWriteTests.cs b/src/Simple.OData.Client.UnitTests/BasicApi/ClientReadWriteTests.cs index 62505ccf..49fbbf6a 100644 --- a/src/Simple.OData.Client.UnitTests/BasicApi/ClientReadWriteTests.cs +++ b/src/Simple.OData.Client.UnitTests/BasicApi/ClientReadWriteTests.cs @@ -31,7 +31,7 @@ public async Task InsertEntrySubcollection() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var ship = await client.InsertEntryAsync("Transport/Ships", new Entry() { { "ShipName", "Test1" } }, true); - ship["ShipName"].Should().Be("Test1"); + Assert.Equal("Test1", ship["ShipName"]); } [Fact] @@ -41,7 +41,7 @@ public async Task UpdateEntryWithResult() var key = new Entry() { { "ProductID", 1 } }; var product = await client.UpdateEntryAsync("Products", key, new Entry() { { "ProductName", "Chai" }, { "UnitPrice", 123m } }, true); - product["UnitPrice"].Should().Be(123m); + Assert.Equal(123m, product["UnitPrice"]); } [Fact] @@ -50,10 +50,10 @@ public async Task UpdateEntryNoResult() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var key = new Entry() { { "ProductID", 1 } }; var product = await client.UpdateEntryAsync("Products", key, new Entry() { { "ProductName", "Chai" }, { "UnitPrice", 123m } }, false); - product.Should().BeNull(); + Assert.Null(product); product = await client.GetEntryAsync("Products", key); - product["UnitPrice"].Should().Be(123m); + Assert.Equal(123m, product["UnitPrice"]); } [Fact] @@ -65,7 +65,7 @@ public async Task UpdateEntrySubcollection() await client.UpdateEntryAsync("Transport/Ships", key, new Entry() { { "ShipName", "Test2" } }); ship = await client.GetEntryAsync("Transport", key); - ship["ShipName"].Should().Be("Test2"); + Assert.Equal("Test2", ship["ShipName"]); } [Fact] @@ -77,7 +77,7 @@ public async Task UpdateEntrySubcollectionWithAnnotations() await client.UpdateEntryAsync("Transport/Ships", key, new Entry() { { "ShipName", "Test2" } }); ship = await client.GetEntryAsync("Transport", key); - ship["ShipName"].Should().Be("Test2"); + Assert.Equal("Test2", ship["ShipName"]); } [Fact] @@ -86,12 +86,12 @@ public async Task DeleteEntry() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); _ = await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test3" }, { "UnitPrice", 18m } }, true); var product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test3'"); - product.Should().NotBeNull(); + Assert.NotNull(product); await client.DeleteEntryAsync("Products", product); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test3'"); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -100,12 +100,12 @@ public async Task DeleteEntrySubCollection() var client = new ODataClient(CreateDefaultSettings().WithHttpMock()); var ship = await client.InsertEntryAsync("Transport/Ships", new Entry() { { "ShipName", "Test3" } }, true); ship = await client.FindEntryAsync("Transport?$filter=TransportID eq " + ship["TransportID"]); - ship.Should().NotBeNull(); + Assert.NotNull(ship); await client.DeleteEntryAsync("Transport", ship); ship = await client.FindEntryAsync("Transport?$filter=TransportID eq " + ship["TransportID"]); - ship.Should().BeNull(); + Assert.Null(ship); } [Fact] @@ -114,12 +114,12 @@ public async Task DeleteEntrySubCollectionWithAnnotations() var client = new ODataClient(CreateDefaultSettings().WithAnnotations().WithHttpMock()); var ship = await client.InsertEntryAsync("Transport/Ships", new Entry() { { "ShipName", "Test3" } }, true); ship = await client.FindEntryAsync("Transport?$filter=TransportID eq " + ship["TransportID"]); - ship.Should().NotBeNull(); + Assert.NotNull(ship); await client.DeleteEntryAsync("Transport", ship); ship = await client.FindEntryAsync("Transport?$filter=TransportID eq " + ship["TransportID"]); - ship.Should().BeNull(); + Assert.Null(ship); } [Theory] @@ -136,8 +136,8 @@ public async Task LinkEntry(bool useAbsoluteReferenceUris) await client.LinkEntryAsync("Products", product, "Category", category); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test5'"); - product["CategoryID"].Should().NotBeNull(); - product["CategoryID"].Should().Be(category["CategoryID"]); + Assert.NotNull(product["CategoryID"]); + Assert.Equal(category["CategoryID"], product["CategoryID"]); } [Theory] @@ -151,12 +151,12 @@ public async Task UnlinkEntry(bool useAbsoluteReferenceUris) var category = await client.InsertEntryAsync("Categories", new Entry() { { "CategoryName", "Test6" } }, true); _ = await client.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test7" }, { "CategoryID", category["CategoryID"] } }, true); var product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test7'"); - product["CategoryID"].Should().NotBeNull(); - product["CategoryID"].Should().Be(category["CategoryID"]); + Assert.NotNull(product["CategoryID"]); + Assert.Equal(category["CategoryID"], product["CategoryID"]); await client.UnlinkEntryAsync("Products", product, "Category"); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test7'"); - product["CategoryID"].Should().BeNull(); + Assert.Null(product["CategoryID"]); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/AggregationTests.cs b/src/Simple.OData.Client.UnitTests/Core/AggregationTests.cs index 91b625d7..be619fc7 100644 --- a/src/Simple.OData.Client.UnitTests/Core/AggregationTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/AggregationTests.cs @@ -47,7 +47,7 @@ public async Task FilterMultipleAnyContains(string metadataFile, string expected .For() .Filter(x => x.Subordinates.Any(y => y.EmployeeID == 1 && y.FirstName.Contains("abc"))); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -61,7 +61,7 @@ public async Task FilterNestedAny(string metadataFile, string expectedCommand) .For() .Filter(x => x.Category.Products.Any(y => y.ProductID == 1)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -75,6 +75,6 @@ public async Task FilterMultipleNestedAny(string metadataFile, string expectedCo .For() .Filter(x => x.Category.Products.Any(y => y.Category.Products.Any(z => z.ProductID == 1))); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/DynamicContainerTests.cs b/src/Simple.OData.Client.UnitTests/Core/DynamicContainerTests.cs index ef2da948..327cb9c4 100644 --- a/src/Simple.OData.Client.UnitTests/Core/DynamicContainerTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/DynamicContainerTests.cs @@ -29,6 +29,6 @@ public void SubTypeContainerName() { TypeCache.Register(); - TypeCache.DynamicContainerName(typeof(Mammal)).Should().Be("DynamicProperties"); + Assert.Equal("DynamicProperties", TypeCache.DynamicContainerName(typeof(Mammal))); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/DynamicDataAggregationTests.cs b/src/Simple.OData.Client.UnitTests/Core/DynamicDataAggregationTests.cs index 22fa25df..51ffb29e 100644 --- a/src/Simple.OData.Client.UnitTests/Core/DynamicDataAggregationTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/DynamicDataAggregationTests.cs @@ -134,7 +134,7 @@ public async Task AggregateWithSumAsDictionary() .Apply(b.Aggregate(new { Total = a.Sum(x.UnitPrice) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28UnitPrice%20with%20sum%20as%20Total%29"); + Assert.Equal("Products?$apply=aggregate%28UnitPrice%20with%20sum%20as%20Total%29", commandText); } [Fact] @@ -164,7 +164,7 @@ public async Task AggregateWithMinAsDictionary() .Apply(b.Aggregate(new { MinPrice = a.Min(x.UnitPrice) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28UnitPrice%20with%20min%20as%20MinPrice%29"); + Assert.Equal("Products?$apply=aggregate%28UnitPrice%20with%20min%20as%20MinPrice%29", commandText); } [Fact] @@ -194,7 +194,7 @@ public async Task AggregateWithMaxAsDictionary() .Apply(b.Aggregate(new { MaxPrice = a.Max(x.UnitPrice) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28UnitPrice%20with%20max%20as%20MaxPrice%29"); + Assert.Equal("Products?$apply=aggregate%28UnitPrice%20with%20max%20as%20MaxPrice%29", commandText); } [Fact] @@ -224,7 +224,7 @@ public async Task AggregateWithDistinctCountAsDictionary() .Apply(b.Aggregate(new { Count = a.CountDistinct(x.ProductName) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28ProductName%20with%20countdistinct%20as%20Count%29"); + Assert.Equal("Products?$apply=aggregate%28ProductName%20with%20countdistinct%20as%20Count%29", commandText); } [Fact] @@ -254,7 +254,7 @@ public async Task AggregateWithCountAsDictionary() .Apply(b.Aggregate(new { Count = a.Count() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28%24count%20as%20Count%29"); + Assert.Equal("Products?$apply=aggregate%28%24count%20as%20Count%29", commandText); } [Fact] @@ -311,7 +311,7 @@ public async Task SimpleGroupByWithMultiplePropertiesAsDictionary() .Apply(b.GroupBy(new { x.Category.CategoryName, x.ProductName })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%2CProductName%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%2CProductName%29%29", commandText); } [Fact] @@ -344,7 +344,7 @@ public async Task GroupByWithAggregationAsDictionary() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29", commandText); } [Fact] @@ -383,7 +383,7 @@ public async Task GroupByWithAggregationOfMultiplePropertiesAsDictionary() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%2C%24count%20as%20Count%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%2C%24count%20as%20Count%29%29", commandText); } [Fact] @@ -466,7 +466,7 @@ public async Task GroupByWithAggregationThenAggregateAsDictionary() .Aggregate(new { MaxPrice = a.Max(x.AverageUnitPrice) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Faggregate%28AverageUnitPrice%20with%20max%20as%20MaxPrice%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Faggregate%28AverageUnitPrice%20with%20max%20as%20MaxPrice%29", commandText); } [Fact] @@ -512,7 +512,7 @@ public async Task GroupByWithAggregationThenGroupByWithAggregationAsDictionary() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Fgroupby%28%28AverageUnitPrice%29%2Caggregate%28%24count%20as%20CategoriesCount%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Fgroupby%28%28AverageUnitPrice%29%2Caggregate%28%24count%20as%20CategoriesCount%29%29", commandText); } [Fact] @@ -597,7 +597,7 @@ public async Task MultipleAppliesAsDictionary() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=filter%28contains%28Category%2FCategoryName%2C%27v%27%29%29%2Fgroupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29"); + Assert.Equal("Products?$apply=filter%28contains%28Category%2FCategoryName%2C%27v%27%29%29%2Fgroupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29", commandText); } [Fact] diff --git a/src/Simple.OData.Client.UnitTests/Core/ExpansionTests.cs b/src/Simple.OData.Client.UnitTests/Core/ExpansionTests.cs index 342beac9..19687f19 100644 --- a/src/Simple.OData.Client.UnitTests/Core/ExpansionTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/ExpansionTests.cs @@ -45,7 +45,7 @@ public async Task ExpandAllSelectAll(string metadataFile, string expectedCommand .Expand("*") .Select("*"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -58,7 +58,7 @@ public async Task ExpandSubordinatesAndSuperior(string metadataFile, string expe .For() .Expand(x => new { x.Subordinates, x.Superior }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -72,7 +72,7 @@ public async Task ExpandSubordinatesAndSuperiorTwoClauses(string metadataFile, s .Expand(x => x.Subordinates) .Expand(x => x.Superior); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -85,7 +85,7 @@ public async Task ExpandSubordinatesTwoTimes(string metadataFile, string expecte .For() .Expand(x => x.Subordinates.Select(y => y.Subordinates)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -98,7 +98,7 @@ public async Task ExpandAllOfSecondSubordinates(string metadataFile, string expe .For() .Expand($"{nameof(Employee.Subordinates)}/*"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -111,7 +111,7 @@ public async Task ExpandSubordinatesThreeTimes(string metadataFile, string expec .For() .Expand(x => x.Subordinates.Select(y => y.Subordinates.Select(z => z.Subordinates))); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -124,7 +124,7 @@ public async Task ExpandAllOfThirdSubordinates(string metadataFile, string expec .For() .Expand($"{nameof(Employee.Subordinates)}/{nameof(Employee.Subordinates)}/*"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -139,7 +139,7 @@ public async Task ExpandSubordinatesWithSelectAndOrderby(string metadataFile, st .Select(x => new { x.LastName, x.Subordinates }) .OrderBy(x => x.LastName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -154,7 +154,7 @@ public async Task ExpandAllWithSelectAndOrderby(string metadataFile, string expe .Select(x => new { x.LastName, x.Subordinates }) .OrderBy(x => x.LastName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -169,7 +169,7 @@ public async Task ExpandSubordinatesWithInnerSelect(string metadataFile, string .Select(x => new { x.LastName, x.Subordinates }) .Select(x => x.Subordinates.Select(y => new { y.LastName, y.Subordinates })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -186,7 +186,7 @@ public async Task ExpandSubordinatesWithSelectAndOrderbyTwoTimes(string metadata .OrderBy(x => x.LastName) .OrderBy(x => x.Subordinates.Select(y => y.LastName)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -203,7 +203,7 @@ public async Task ExpandAllOfSecondSubordinatesWithSelectAndOrderby(string metad .OrderBy(x => x.LastName) .OrderBy(x => x.Subordinates.Select(y => y.LastName)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -212,10 +212,10 @@ public async Task ExpandAllOfSecondSubordinatesWithSelectAndOrderby(string metad public void ExpandSubordinatesWithSelectAndInnerOrderby(string metadataFile) { var client = CreateClient(metadataFile); - (() => client + Assert.Throws(() => client .For() .Expand(x => x.Subordinates.Select(y => y.Subordinates)) - .Select(x => x.Subordinates.Select(y => new { y.LastName, y.Subordinates }).OrderBy(y => y.LastName))).Should().ThrowExactly(); + .Select(x => x.Subordinates.Select(y => new { y.LastName, y.Subordinates }).OrderBy(y => y.LastName))); } [Theory] @@ -234,7 +234,7 @@ public async Task ExpandSubordinatesWithSelectAndOrderbyThreeTimes(string metada .OrderBy(x => x.Subordinates.Select(y => y.LastName)) .OrderBy(x => x.Subordinates.Select(y => y.Subordinates.Select(z => z.LastName))); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -253,7 +253,7 @@ public async Task ExpandAllOfThirdSubordinatesWithSelectAndOrderby(string metada .OrderBy(x => x.Subordinates.Select(y => y.LastName)) .OrderBy(x => x.Subordinates.Select(y => y.Subordinates.Select(z => z.LastName))); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -268,7 +268,7 @@ public async Task ExpandSubordinatesWithSelectThenDeepOrderby(string metadataFil .Select(x => new { x.LastName, x.Subordinates }) .OrderBy(x => x.Superior.LastName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -283,7 +283,7 @@ public async Task ExpandAllWithSelectThenDeepOrderby(string metadataFile, string .Select(x => new { x.LastName, x.Subordinates }) .OrderBy(x => x.Superior.LastName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -297,7 +297,7 @@ public async Task SelectAndDeepOrderby(string metadataFile, string expectedComma .Select(x => new { x.LastName, x.Subordinates }) .OrderBy(x => x.Superior.LastName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -311,7 +311,7 @@ public async Task SelectAllAndDeepOrderby(string metadataFile, string expectedCo .Select("*") .OrderBy(x => x.Superior.LastName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -324,7 +324,7 @@ public async Task ExpandCategorySelectProductNameCategoryName(string metadataFil .Expand(p => p.Category) .Select(p => new { p.ProductName, p.Category.CategoryName }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -336,7 +336,7 @@ public async Task ExpandSuperiorWithSubordinates(string metadataFile, string exp var command = client.For() .Expand(x => x.Superior.Subordinates); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -352,7 +352,7 @@ public async Task ExpandSuperiorWithSubordinatesAndSuperiorInMultipleExpands(str .Expand(x => x.Superior.Superior); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -364,7 +364,7 @@ public async Task ExpandSuperiorThreeTimes(string metadataFile, string expectedC var command = client.For() .Expand(x => x.Superior.Superior.Superior); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -377,7 +377,7 @@ public async Task ExpandAllSelectProductNameCategoryName(string metadataFile, st .Expand("*") .Select(p => new { p.ProductName, p.Category.CategoryName }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -391,7 +391,7 @@ public async Task ExpandCategorySelectProductNameCategoryNameThenOrderBy(string .Select(p => new { p.ProductName, p.Category.CategoryName }) .OrderBy(p => p.Category.CategoryName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -405,7 +405,7 @@ public async Task ExpandAllSelectProductNameCategoryNameThenOrderBy(string metad .Select(p => new { p.ProductName, p.Category.CategoryName }) .OrderBy(p => p.Category.CategoryName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -420,7 +420,7 @@ public async Task ExpandCategorySelectProductNameCategoryNameThenOrderByCategory .OrderBy(p => p.Category.CategoryName) .ThenBy(p => p.ProductName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -435,7 +435,7 @@ public async Task ExpandAllSelectProductNameCategoryNameThenOrderByCategoryNameT .OrderBy(p => p.Category.CategoryName) .ThenBy(p => p.ProductName); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -461,7 +461,7 @@ public async Task ExpandNavigationPropertyAndPropertyWithContainedName_Issue801( .ThenBy(p => p.Quantity); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Fact] @@ -473,7 +473,7 @@ public async Task ExpandSubordinates2LevelsByValue() .Expand(ODataExpandOptions.ByValue(2), x => x.Subordinates); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Employees?$expand=Subordinates($levels=2)"); + Assert.Equal("Employees?$expand=Subordinates($levels=2)", commandText); } [Fact] @@ -485,7 +485,7 @@ public async Task ExpandSubordinates2LevelsByReference() .Expand(ODataExpandOptions.ByReference(2), x => x.Subordinates); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Employees?$expand=Subordinates/$ref($levels=2)"); + Assert.Equal("Employees?$expand=Subordinates/$ref($levels=2)", commandText); } [Fact] @@ -545,7 +545,7 @@ public async Task ExpandFunctionMultipleLevelsWithSelect() var commandText = await command.GetCommandTextAsync(); Console.WriteLine(commandText); - commandText.Should().Be(expectedResult); + Assert.Equal(expectedResult, commandText); } [Fact] @@ -556,7 +556,7 @@ public async Task ExpandProductsFilterByUnitPrice() .For() .Expand(x => x.Products.Where(p => p.UnitPrice > 18)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Categories?$expand=Products($filter=UnitPrice%20gt%2018)"); + Assert.Equal("Categories?$expand=Products($filter=UnitPrice%20gt%2018)", commandText); } [Fact] @@ -567,7 +567,7 @@ public async Task ExpandProductsOrderByUnitPriceThenByProductName() .For() .Expand(x => x.Products.OrderBy(p => p.UnitPrice).ThenBy(p => p.ProductName)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Categories?$expand=Products($orderby=UnitPrice,ProductName)"); + Assert.Equal("Categories?$expand=Products($orderby=UnitPrice,ProductName)", commandText); } [Fact] @@ -578,7 +578,7 @@ public async Task ExpandProductsOrderByCategoryName() .For() .Expand(x => x.Products.OrderBy(p => p.Category.CategoryName)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Categories?$expand=Products($orderby=Category/CategoryName)"); + Assert.Equal("Categories?$expand=Products($orderby=Category/CategoryName)", commandText); } [Fact] @@ -589,7 +589,7 @@ public async Task ExpandProductsOrderByUnitPriceDescendingThenByProductNameDesce .For() .Expand(x => x.Products.OrderByDescending(p => p.UnitPrice).ThenByDescending(p => p.ProductName)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Categories?$expand=Products($orderby=UnitPrice desc,ProductName desc)"); + Assert.Equal("Categories?$expand=Products($orderby=UnitPrice desc,ProductName desc)", commandText); } [Fact] @@ -601,18 +601,18 @@ public async Task ExpandSuperiorWithSubordinatesAndTheirSuperiorsAndDeepOrderby( .Expand(x => x.Superior.Subordinates.Select(s => s.Superior)) .Expand(x => x.Superior.Subordinates.OrderBy(s => s.LastName)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); command = client.For() .Expand(x => x.Superior.Subordinates.OrderBy(s => s.LastName)) .Expand(x => x.Superior.Subordinates.Select(s => s.Superior)); commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); command = client.For() .Expand(x => x.Superior.Subordinates.OrderBy(s => s.LastName).Select(s => s.Superior)); commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Fact] @@ -624,6 +624,6 @@ public async Task ExpandProductsSelectProductNameAndUnitPriceThenOrderByUnitPric .Expand(x => x.Products.Select(p => new { p.ProductName, p.UnitPrice })) .Expand(x => x.Products.OrderByDescending(p => p.UnitPrice).ThenByDescending(p => p.ProductName)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Categories?$expand=Products($select=ProductName,UnitPrice;$orderby=UnitPrice desc,ProductName desc)"); + Assert.Equal("Categories?$expand=Products($select=ProductName,UnitPrice;$orderby=UnitPrice desc,ProductName desc)", commandText); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/KeyTests.cs b/src/Simple.OData.Client.UnitTests/Core/KeyTests.cs index 4c5b5a46..01e5ddd0 100644 --- a/src/Simple.OData.Client.UnitTests/Core/KeyTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/KeyTests.cs @@ -47,7 +47,7 @@ public async Task PrimaryKey_MultipleProperty_NoNames(string metadataFile, strin .For() .Key(1, 2); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -61,7 +61,7 @@ public async Task PrimaryKey_MultipleProperty_Named(string metadataFile, string .For() .Key(new { ProductID = 2, OrderID = 1 }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -75,7 +75,7 @@ public async Task PrimaryKey_MultipleProperty_FromEntity(string metadataFile, st .For() .Key(new OrderDetail { ProductID = 2, OrderID = 1, Quantity = 5 }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -89,7 +89,7 @@ public async Task PrimaryKey_SingleProperty_FromEntity(string metadataFile, stri .For() .Key(new Category { CategoryID = 1 }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -103,7 +103,7 @@ public async Task PrimaryKey_SingleProperty_FromFilter(string metadataFile, stri .For() .Filter(x => x.CategoryID == 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -117,7 +117,7 @@ public async Task PrimaryKey_SingleProperty_NoMatchinhFilter(string metadataFile .For() .Filter(x => x.CategoryID == 1 && x.CategoryName == "Test"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -130,7 +130,7 @@ public async Task PrimaryKey_SingleProperty_NavigationKeyFilter(string metadataF .For() .Filter(x => x.Ticket.Id == 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -143,7 +143,7 @@ public async Task PrimaryKey_SingleProperty_ComplexKeyFilter(string metadataFile .For() .Filter(x => x.Option.Id == 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -157,7 +157,7 @@ public async Task AlternateKey_SingleProperty(string metadataFile, string expect .For() .Key(new { CategoryName = "Beverages" }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -171,7 +171,7 @@ public async Task AlternateKey_SingleProperty_As_Filter(string metadataFile, str .For() .Filter(x => x.CategoryName == "Beverages"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -185,7 +185,7 @@ public async Task AlternateKey_MultipleProperty(string metadataFile, string expe .For() .Key(new { HomePhone = "123", Title = "Manager" }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -199,7 +199,7 @@ public async Task AlternateKey_MultipleProperty_FromFilter(string metadataFile, .For() .Filter(x => x.HomePhone == "123" && x.Title == "Manager"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -213,7 +213,7 @@ public async Task AlternateKey_MultipleKeys_Key1(string metadataFile, string exp .For() .Key(new { CustomerID = "ALFKI" }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } [Theory] @@ -227,6 +227,6 @@ public async Task AlternateKey_MultipleKeys_Key2(string metadataFile, string exp .For() .Key(new { ShipName = "TEST" }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(expectedCommand); + Assert.Equal(expectedCommand, commandText); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/ODataExpandAssociationTests.cs b/src/Simple.OData.Client.UnitTests/Core/ODataExpandAssociationTests.cs index 660707d7..c1747cc7 100644 --- a/src/Simple.OData.Client.UnitTests/Core/ODataExpandAssociationTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/ODataExpandAssociationTests.cs @@ -20,21 +20,21 @@ public void CreateExpandAssociationWithNestedAssociations() association.Name.Should().Be("Products"); Assert.Single(association.ExpandAssociations); - association.ExpandAssociations.First().Name.Should().Be("Category"); + Assert.Equal("Category", association.ExpandAssociations.First().Name); Assert.Single(association.ExpandAssociations.First().ExpandAssociations); - association.ExpandAssociations.First().ExpandAssociations.First().Name.Should().Be("Orders"); + Assert.Equal("Orders", association.ExpandAssociations.First().ExpandAssociations.First().Name); } [Fact] public void CreateExpandAssociationFromNullStringThrowsArgumentException() { - (() => ODataExpandAssociation.From(null)).Should().ThrowExactly(); + Assert.Throws(() => ODataExpandAssociation.From(null)); } [Fact] public void CreateExpandAssociationFromEmptyStringThrowsArgumentException() { - (() => ODataExpandAssociation.From(string.Empty)).Should().ThrowExactly(); + Assert.Throws(() => ODataExpandAssociation.From(string.Empty)); } [Fact] @@ -47,7 +47,7 @@ public void CloneProducesNewObjects() var clonedAssociation = association.Clone(); - clonedAssociation.Should().NotBeSameAs(association); - clonedAssociation.ExpandAssociations.First().Should().NotBeSameAs(association.ExpandAssociations.First()); + Assert.NotSame(association, clonedAssociation); + Assert.NotSame(association.ExpandAssociations.First(), clonedAssociation.ExpandAssociations.First()); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/OpenTypesTests.cs b/src/Simple.OData.Client.UnitTests/Core/OpenTypesTests.cs index aa937da8..4d2333a4 100644 --- a/src/Simple.OData.Client.UnitTests/Core/OpenTypesTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/OpenTypesTests.cs @@ -24,9 +24,9 @@ public async Task ReadUntypedAsStrings() var entry = result.Entries.First(); entry.Should().NotBeNull(); entry.Data["Id"].Should().Be(42m); - entry.Data["IntegerProperty"].Should().Be(43m); - entry.Data["NullProperty"].Should().BeNull(); - entry.Data["StringProperty"].Should().Be("some string"); + Assert.Equal(43m, entry.Data["IntegerProperty"]); + Assert.Null(entry.Data["NullProperty"]); + Assert.Equal("some string", entry.Data["StringProperty"]); } private static new IODataResponseMessageAsync SetUpResourceMock(string resourceName) diff --git a/src/Simple.OData.Client.UnitTests/Core/PluralizerTests.cs b/src/Simple.OData.Client.UnitTests/Core/PluralizerTests.cs index 588fe0f9..b46ab157 100644 --- a/src/Simple.OData.Client.UnitTests/Core/PluralizerTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/PluralizerTests.cs @@ -39,28 +39,28 @@ public void SingularizeWord(string word, string expectedResult) [InlineData("Språk", "Språk")] public void PluralizeWordWithNonEnglishCharacters(string word, string expectedResult) { - _pluralizer.Pluralize(word).Should().Be(expectedResult); + Assert.Equal(expectedResult, _pluralizer.Pluralize(word)); } [Theory] [InlineData("Gårds", "Gårds")] public void SingularizeWordWithNonEnglishCharacters(string word, string expectedResult) { - _pluralizer.Singularize(word).Should().Be(expectedResult); + Assert.Equal(expectedResult, _pluralizer.Singularize(word)); } [Theory] [InlineData("Catalog_Контрагенты", "Catalog_Контрагенты")] public void PluralizeWordWithNonLatinCharacters(string word, string expectedResult) { - _pluralizer.Pluralize(word).Should().Be(expectedResult); + Assert.Equal(expectedResult, _pluralizer.Pluralize(word)); } [Theory] [InlineData("Catalog_Контрагенты", "Catalog_Контрагенты")] public void SingularizeWordWithNonLatinCharacters(string word, string expectedResult) { - _pluralizer.Singularize(word).Should().Be(expectedResult); + Assert.Equal(expectedResult, _pluralizer.Singularize(word)); } [Theory] @@ -72,7 +72,7 @@ public void SingularizeWordWithNonLatinCharacters(string word, string expectedRe [InlineData("Catalog_Контрагенты_123", "catalogконтрагенты123")] public void HomogenizeWord(string word, string expectedResult) { - word.Homogenize().Should().Be(expectedResult); + Assert.Equal(expectedResult, word.Homogenize()); } } @@ -90,7 +90,7 @@ public async Task TableWithNonLaticCharacters() .Top(10) .GetCommandTextAsync(); - commandText.Should().Be("Catalog_Контрагенты?$top=10"); + Assert.Equal("Catalog_Контрагенты?$top=10", commandText); } [Fact] @@ -102,6 +102,6 @@ public async Task TableWithNonLaticCharacters_NoPluralizer() .Top(10) .GetCommandTextAsync(); - commandText.Should().Be("Catalog_Контрагенты?$top=10"); + Assert.Equal("Catalog_Контрагенты?$top=10", commandText); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/RequestWriterActionTests.cs b/src/Simple.OData.Client.UnitTests/Core/RequestWriterActionTests.cs index 56e1f4e6..b9ed94c9 100644 --- a/src/Simple.OData.Client.UnitTests/Core/RequestWriterActionTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/RequestWriterActionTests.cs @@ -38,7 +38,7 @@ public async Task CreateActionRequestWithDerivedType() var orderClose = result["OrderClose"]; orderClose.Should().NotBeNull(); - orderClose["@odata.type"].Should().NotBeNull(); - (((JValue)orderClose["@odata.type"]).Value as string).Should().Be("#Microsoft.Dynamics.CRM.orderclose"); + Assert.NotNull(orderClose["@odata.type"]); + Assert.Equal("#Microsoft.Dynamics.CRM.orderclose", ((JValue)orderClose["@odata.type"]).Value as string); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/RequestWriterBatchTests.cs b/src/Simple.OData.Client.UnitTests/Core/RequestWriterBatchTests.cs index d2d3baf8..78256754 100644 --- a/src/Simple.OData.Client.UnitTests/Core/RequestWriterBatchTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/RequestWriterBatchTests.cs @@ -70,6 +70,6 @@ public async Task CreateUpdateRequest_NoPreferredVerb_AllProperties_OperationHea result.Method.Should().Be("PATCH"); (result.Headers.TryGetValue("Header1", out var value) && value == "HeaderValue1").Should().BeTrue(); - (result.RequestMessage.Headers.TryGetValues("Header1", out var values) && values.Contains("HeaderValue1")).Should().BeTrue(); + Assert.True(result.RequestMessage.Headers.TryGetValues("Header1", out var values) && values.Contains("HeaderValue1")); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/RequestWriterTests.cs b/src/Simple.OData.Client.UnitTests/Core/RequestWriterTests.cs index 1317ec32..d7d69439 100644 --- a/src/Simple.OData.Client.UnitTests/Core/RequestWriterTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/RequestWriterTests.cs @@ -86,7 +86,7 @@ public async Task CreateUpdateRequest_PreferredVerbPut_AllProperties_Put() { "ReorderLevel", 500 }, { "Discontinued", false }, }, false); - result.Method.Should().Be("PUT"); + Assert.Equal("PUT", result.Method); } finally { @@ -114,7 +114,7 @@ public async Task CreateUpdateRequest_PreferredVerbPatch_ChangedKey_Put() { "ReorderLevel", 500 }, { "Discontinued", false }, }, false); - result.Method.Should().Be("PUT"); + Assert.Equal("PUT", result.Method); } [Fact] @@ -127,7 +127,7 @@ public async Task CreateInsertRequest_Post() { "FirstName", "John" }, { "LastName", "Smith" }, }, false); - result.Method.Should().Be("POST"); + Assert.Equal("POST", result.Method); } [Fact] @@ -141,7 +141,7 @@ public async Task CreateInsertRequest_DateTime_Not_Null_Post() { "LastName", "Smith" }, { "BirthDate", DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Unspecified) }, }, false); - result.Method.Should().Be("POST"); + Assert.Equal("POST", result.Method); } [Fact] @@ -155,7 +155,7 @@ public async Task CreateInsertRequest_DateTime_Null_Post() { "LastName", "Smith" }, { "BirthDate", null }, }, false); - result.Method.Should().Be("POST"); + Assert.Equal("POST", result.Method); } [Fact] @@ -169,7 +169,7 @@ public async Task CreateInsertRequest_DateTimeOffset_Not_Null_Post() { "LastName", "Smith" }, { "BirthDate", DateTimeOffset.Now }, }, false); - result.Method.Should().Be("POST"); + Assert.Equal("POST", result.Method); } [Fact] @@ -183,7 +183,7 @@ public async Task CreateInsertRequest_DateTimeOffset_Null_Post() { "LastName", "Smith" }, { "BirthDate", null }, }, false); - result.Method.Should().Be("POST"); + Assert.Equal("POST", result.Method); } [Fact] @@ -197,7 +197,7 @@ public async Task CreateInsertRequest_Date_Not_Null_Post() { "LastName", "Smith" }, { "HireDate", DateTimeOffset.Now }, }, false); - result.Method.Should().Be("POST"); + Assert.Equal("POST", result.Method); } [Fact] @@ -211,7 +211,7 @@ public async Task CreateInsertRequest_Date_Null_Post() { "LastName", "Smith" }, { "HireDate", null }, }, false); - result.Method.Should().Be("POST"); + Assert.Equal("POST", result.Method); } [Fact] @@ -229,7 +229,7 @@ public async Task CreateInsertRequest_With_Headers() { "header2" , "header2Value" } }); - result.Headers["header1"].Should().Be("header1Value"); - result.Headers["header2"].Should().Be("header2Value"); + Assert.Equal("header1Value", result.Headers["header1"]); + Assert.Equal("header2Value", result.Headers["header2"]); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/ResponseReaderV3Tests.cs b/src/Simple.OData.Client.UnitTests/Core/ResponseReaderV3Tests.cs index 2d41bc63..4911de78 100644 --- a/src/Simple.OData.Client.UnitTests/Core/ResponseReaderV3Tests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/ResponseReaderV3Tests.cs @@ -86,7 +86,7 @@ public async Task GetSingleProductWithComplexProperty() var quantity = result["Quantity"] as IDictionary; quantity.Should().NotBeNull(); quantity["Value"].Should().Be(10d); - quantity["Units"].Should().Be("bags"); + Assert.Equal("bags", quantity["Units"]); } [Fact] @@ -193,7 +193,7 @@ private static Task ParseSchema(string schemaName) var entityType = metadata.SchemaElements .Single(x => x.SchemaElementKind == EdmSchemaElementKind.TypeDefinition && (x as IEdmType).TypeKind == EdmTypeKind.Entity); - entityType.Name.Should().Be(schemaName); + Assert.Equal(schemaName, entityType.Name); return Task.FromResult(0); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/ResponseReaderV4Tests.cs b/src/Simple.OData.Client.UnitTests/Core/ResponseReaderV4Tests.cs index b5608250..204b2a94 100644 --- a/src/Simple.OData.Client.UnitTests/Core/ResponseReaderV4Tests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/ResponseReaderV4Tests.cs @@ -38,8 +38,8 @@ public async Task ExampleActionReturnsComplexType() var responseReader = new ResponseReader(_session, await _client.GetMetadataAsync()); var result = (await responseReader.GetResponseAsync(response)).Feed; var entry = result.Entries.First(); - entry.Should().NotBeNull(); - entry.Data["SomeProperty"].Should().Be("MyPropertyValue"); + Assert.NotNull(entry); + Assert.Equal("MyPropertyValue", entry.Data["SomeProperty"]); } private static new IODataResponseMessageAsync SetUpResourceMock(string resourceName) diff --git a/src/Simple.OData.Client.UnitTests/Core/SettingsTests.cs b/src/Simple.OData.Client.UnitTests/Core/SettingsTests.cs index 9ef86e3c..d1288988 100644 --- a/src/Simple.OData.Client.UnitTests/Core/SettingsTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/SettingsTests.cs @@ -23,7 +23,7 @@ public void DefaultCtorAndBaseUri() public void CtorWithBaseUri() { var settings = new ODataClientSettings(new Uri("http://localhost")); - settings.BaseUri.AbsoluteUri.Should().Be("http://localhost/"); + Assert.Equal("http://localhost/", settings.BaseUri.AbsoluteUri); } [Fact] @@ -32,14 +32,14 @@ public void CtorWithBaseUriTypeCache() var settings = new ODataClientSettings(new Uri("http://localhost")); var settings2 = new ODataClientSettings(new Uri("http://localhost")); - settings2.TypeCache.Should().BeSameAs(settings.TypeCache); + Assert.Same(settings.TypeCache, settings2.TypeCache); } [Fact] public void CtorWithHttpClient() { var settings = new ODataClientSettings(new HttpClient()); - settings.BaseUri.Should().BeNull(); + Assert.Null(settings.BaseUri); } [Fact] @@ -53,7 +53,7 @@ public void CtorWithHttpClientTypeCache() public void CtorWithHttpClientNoBaseAddressAndBaseUri() { var settings = new ODataClientSettings(new HttpClient()) { BaseUri = new Uri("http://localhost") }; - settings.BaseUri.AbsoluteUri.Should().Be("http://localhost/"); + Assert.Equal("http://localhost/", settings.BaseUri.AbsoluteUri); } [Fact] @@ -62,7 +62,7 @@ public void CtorWithHttpClientNoBaseAddressAndBaseUriTypeCache() var settings = new ODataClientSettings(new HttpClient()) { BaseUri = new Uri("http://localhost") }; var settings2 = new ODataClientSettings(new HttpClient()) { BaseUri = new Uri("http://localhost") }; - settings2.TypeCache.Should().BeSameAs(settings.TypeCache); + Assert.Same(settings.TypeCache, settings2.TypeCache); } [Fact] @@ -75,7 +75,7 @@ public void CtorWithHttpClientNoBaseAddressAndRelativeUri() public void CtorWithHttpClientAndBaseAddress() { var settings = new ODataClientSettings(new HttpClient { BaseAddress = new Uri("http://localhost") }); - settings.BaseUri.AbsoluteUri.Should().Be("http://localhost/"); + Assert.Equal("http://localhost/", settings.BaseUri.AbsoluteUri); } [Fact] @@ -84,7 +84,7 @@ public void CtorWithHttpClientAndBaseAddressTypeCache() var settings = new ODataClientSettings(new HttpClient { BaseAddress = new Uri("http://localhost") }); var settings2 = new ODataClientSettings(new HttpClient { BaseAddress = new Uri("http://localhost") }); - settings2.TypeCache.Should().BeSameAs(settings.TypeCache); + Assert.Same(settings.TypeCache, settings2.TypeCache); } [Fact] @@ -97,7 +97,7 @@ public void CtorWithHttpClientAndRelativeBaseAddress() public void CtorWithHttpClientAndBaseAddressAndRelativeUrl() { var settings = new ODataClientSettings(new HttpClient { BaseAddress = new Uri("http://localhost") }, new Uri("api", UriKind.Relative)); - settings.BaseUri.AbsoluteUri.Should().Be("http://localhost/api"); + Assert.Equal("http://localhost/api", settings.BaseUri.AbsoluteUri); } [Fact] @@ -106,7 +106,7 @@ public void CtorWithHttpClientAndBaseAddressAndRelativeUrlTypeCache() var settings = new ODataClientSettings(new HttpClient { BaseAddress = new Uri("http://localhost") }, new Uri("api", UriKind.Relative)); var settings2 = new ODataClientSettings(new HttpClient { BaseAddress = new Uri("http://localhost") }, new Uri("api", UriKind.Relative)); - settings2.TypeCache.Should().BeSameAs(settings.TypeCache); + Assert.Same(settings.TypeCache, settings2.TypeCache); } [Fact] diff --git a/src/Simple.OData.Client.UnitTests/Core/TypeCacheValueConversionTests.cs b/src/Simple.OData.Client.UnitTests/Core/TypeCacheValueConversionTests.cs index 1637049e..b2b458e5 100644 --- a/src/Simple.OData.Client.UnitTests/Core/TypeCacheValueConversionTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/TypeCacheValueConversionTests.cs @@ -53,8 +53,8 @@ public void TryConvert(object value, Type sourceType, Type targetType) sourceValue = ChangeType(value, targetType); result = TypeCache.TryConvert(sourceValue, sourceType, out targetValue); - result.Should().BeTrue(); - ChangeType(targetValue, sourceType).Should().Be(ChangeType(sourceValue, sourceType)); + Assert.True(result); + Assert.Equal(ChangeType(sourceValue, sourceType), ChangeType(targetValue, sourceType)); } [Fact] @@ -62,7 +62,7 @@ public void TryConvert_GeographyPoint() { var source = GeographyPoint.Create(10, 10); var result = TypeCache.TryConvert(source, typeof(GeographyPoint), out _); - result.Should().BeTrue(); + Assert.True(result); } [Theory] @@ -72,8 +72,8 @@ public void TryConvertODataEdmDate(object value, Type sourceType, Type targetTyp { var sourceValue = ChangeType(value, sourceType); var result = TypeCache.TryConvert(sourceValue, targetType, out var targetValue); - result.Should().BeTrue(); - ChangeType(targetValue, targetType).Should().Be(ChangeType(sourceValue, targetType)); + Assert.True(result); + Assert.Equal(ChangeType(sourceValue, targetType), ChangeType(targetValue, targetType)); } [Theory] @@ -83,7 +83,7 @@ public void TryConvertValueWithoutImplicitDateConversionFails(object value, Type { var sourceValue = ChangeType(value, sourceType); var result = TypeCache.TryConvert(sourceValue, targetType, out _); - result.Should().BeFalse(); + Assert.False(result); } [Fact] @@ -94,7 +94,7 @@ public void TryConvert_CustomType_WithTypeConverterLambda() var source = Guid.NewGuid(); var result = TypeCache.TryConvert(source, typeof(PrimitiveType), out var converted); - result.Should().BeTrue(); + Assert.True(result); Assert.Equal(source, ((PrimitiveType)converted).Value); } @@ -106,7 +106,7 @@ public void TryConvert_CustomType_WithTypeConverterLambda_Nullable() var source = (Guid?)Guid.NewGuid(); var result = TypeCache.TryConvert(source, typeof(PrimitiveType?), out var converted); - result.Should().BeTrue(); + Assert.True(result); Assert.Equal(source, ((PrimitiveType)converted).Value); } @@ -115,7 +115,7 @@ public void TryConvert_CustomType_WithTypeConverterComponent() { var source = Guid.NewGuid(); var result = TypeCache.TryConvert(source, typeof(PrimitiveType), out var converted); - result.Should().BeTrue(); + Assert.True(result); Assert.Equal(source, ((PrimitiveType)converted).Value); } @@ -124,7 +124,7 @@ public void TryConvert_CustomType_WithTypeConverterComponent_Nullable() { var source = (Guid?)Guid.NewGuid(); var result = TypeCache.TryConvert(source, typeof(PrimitiveType?), out var converted); - result.Should().BeTrue(); + Assert.True(result); Assert.Equal(source, ((PrimitiveType)converted).Value); } diff --git a/src/Simple.OData.Client.UnitTests/Core/TypeConverterCacheTests.cs b/src/Simple.OData.Client.UnitTests/Core/TypeConverterCacheTests.cs index b1b7800d..d21cf01d 100644 --- a/src/Simple.OData.Client.UnitTests/Core/TypeConverterCacheTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/TypeConverterCacheTests.cs @@ -29,6 +29,6 @@ public void GlobalConverters() var c1 = CustomConverters.Converter("global"); var c2 = CustomConverters.Global; - c2.Should().BeSameAs(c1); + Assert.Same(c1, c2); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/TypedDataAggregationTests.cs b/src/Simple.OData.Client.UnitTests/Core/TypedDataAggregationTests.cs index 64531265..f3d7ec17 100644 --- a/src/Simple.OData.Client.UnitTests/Core/TypedDataAggregationTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/TypedDataAggregationTests.cs @@ -46,7 +46,7 @@ public async Task AggregateWithAverageAsConcreteDestinationType() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29"); + Assert.Equal("Products?$apply=aggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29", commandText); } [Fact] @@ -58,7 +58,7 @@ public async Task AggregateWithSum() .Apply(b => b.Aggregate((x, a) => new { Total = a.Sum(x.UnitPrice) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28UnitPrice%20with%20sum%20as%20Total%29"); + Assert.Equal("Products?$apply=aggregate%28UnitPrice%20with%20sum%20as%20Total%29", commandText); } [Fact] @@ -70,7 +70,7 @@ public async Task AggregateWithMin() .Apply(b => b.Aggregate((x, a) => new { MinPrice = a.Min(x.UnitPrice) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28UnitPrice%20with%20min%20as%20MinPrice%29"); + Assert.Equal("Products?$apply=aggregate%28UnitPrice%20with%20min%20as%20MinPrice%29", commandText); } [Fact] @@ -82,7 +82,7 @@ public async Task AggregateWithMax() .Apply(b => b.Aggregate((x, a) => new { MaxPrice = a.Max(x.UnitPrice) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28UnitPrice%20with%20max%20as%20MaxPrice%29"); + Assert.Equal("Products?$apply=aggregate%28UnitPrice%20with%20max%20as%20MaxPrice%29", commandText); } [Fact] @@ -94,7 +94,7 @@ public async Task AggregateWithDistinctCount() .Apply(b => b.Aggregate((x, a) => new { Count = a.CountDistinct(x.ProductName) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28ProductName%20with%20countdistinct%20as%20Count%29"); + Assert.Equal("Products?$apply=aggregate%28ProductName%20with%20countdistinct%20as%20Count%29", commandText); } [Fact] @@ -106,7 +106,7 @@ public async Task AggregateWithCount() .Apply(b => b.Aggregate((x, a) => new { Count = a.Count() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=aggregate%28%24count%20as%20Count%29"); + Assert.Equal("Products?$apply=aggregate%28%24count%20as%20Count%29", commandText); } [Fact] @@ -118,7 +118,7 @@ public async Task SimpleGroupBy() .Apply(b => b.GroupBy((x, _) => x.Category.CategoryName)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%29", commandText); } [Fact] @@ -134,7 +134,7 @@ public async Task SimpleGroupByWithMultipleProperties() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%2CProductName%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%2CProductName%29%29", commandText); } [Fact] @@ -150,7 +150,7 @@ public async Task GroupByWithAggregation() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29", commandText); } [Fact] @@ -170,7 +170,7 @@ public async Task GroupByWithAggregationAndNestedAssignments() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28ProductName%2CCategory%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29"); + Assert.Equal("Products?$apply=groupby%28%28ProductName%2CCategory%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29", commandText); } [Fact] @@ -187,7 +187,7 @@ public async Task GroupByWithAggregationOfMultipleProperties() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%2C%24count%20as%20Count%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%2C%24count%20as%20Count%29%29", commandText); } [Fact] @@ -206,7 +206,7 @@ public async Task FilterThenGroupByWithAggregationAsConcreteDestinationType() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=filter%28%28Category%2FCategoryName%20in%20%28%27Beverage%27%2C%27Food%27%29%29%29%2Fgroupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29"); + Assert.Equal("Products?$apply=filter%28%28Category%2FCategoryName%20in%20%28%27Beverage%27%2C%27Food%27%29%29%29%2Fgroupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29", commandText); } [Fact] @@ -224,7 +224,7 @@ public async Task GroupByWithAggregationThenFilter() .Filter(x => x.MaxUnitPrice > 100)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20max%20as%20MaxUnitPrice%29%29%2Ffilter%28MaxUnitPrice%20gt%20100%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20max%20as%20MaxUnitPrice%29%29%2Ffilter%28MaxUnitPrice%20gt%20100%29", commandText); } [Fact] @@ -242,7 +242,7 @@ public async Task GroupByWithAggregationThenAggregate() .Aggregate((x, a) => new { MaxPrice = a.Max(x.AverageUnitPrice) })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Faggregate%28AverageUnitPrice%20with%20max%20as%20MaxPrice%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Faggregate%28AverageUnitPrice%20with%20max%20as%20MaxPrice%29", commandText); } [Fact] @@ -264,7 +264,7 @@ public async Task GroupByWithAggregationThenGroupByWithAggregation() })); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Fgroupby%28%28AverageUnitPrice%29%2Caggregate%28%24count%20as%20CategoriesCount%29%29"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Fgroupby%28%28AverageUnitPrice%29%2Caggregate%28%24count%20as%20CategoriesCount%29%29", commandText); } [Fact] @@ -281,7 +281,7 @@ public async Task GroupByWithAggregationThenOrderBy() .OrderBy(x => x.AverageUnitPrice); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29&$orderby=AverageUnitPrice"); + Assert.Equal("Products?$apply=groupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29&$orderby=AverageUnitPrice", commandText); } [Fact] @@ -299,7 +299,7 @@ public async Task MultipleApplies() .Apply(b => b.Filter(x => x.AverageUnitPrice > 100)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$apply=filter%28contains%28Category%2FCategoryName%2C%27ab%27%29%29%2Fgroupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Ffilter%28AverageUnitPrice%20gt%20100%29"); + Assert.Equal("Products?$apply=filter%28contains%28Category%2FCategoryName%2C%27ab%27%29%29%2Fgroupby%28%28Category%2FCategoryName%29%2Caggregate%28UnitPrice%20with%20average%20as%20AverageUnitPrice%29%29%2Ffilter%28AverageUnitPrice%20gt%20100%29", commandText); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/TypedExpressionsTests.cs b/src/Simple.OData.Client.UnitTests/Core/TypedExpressionsTests.cs index b3a42143..4641174e 100644 --- a/src/Simple.OData.Client.UnitTests/Core/TypedExpressionsTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/TypedExpressionsTests.cs @@ -37,7 +37,7 @@ public void FilterEntitiesByNestedPropertyWithContains() { var categories = new List { "Chai", "Milk", "Water" }; Expression> filter = x => categories.Contains(x.Nested.ProductName); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("(Nested/ProductName in ('Chai','Milk','Water'))"); + Assert.Equal("(Nested/ProductName in ('Chai','Milk','Water'))", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -45,7 +45,7 @@ public void FilterEntitiesByComplexConditionWithContains() { var categories = new List { "chai", "milk", "water" }; Expression> filter = x => categories.Contains(x.ProductName.ToLower()); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("(tolower(ProductName) in ('chai','milk','water'))"); + Assert.Equal("(tolower(ProductName) in ('chai','milk','water'))", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -53,7 +53,7 @@ public void FilterEntitiesWithNotContains() { var ids = new List { 1, 2, 3 }; Expression> filter = x => !ids.Contains(x.ProductID); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("not (ProductID in (1,2,3))"); + Assert.Equal("not (ProductID in (1,2,3))", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -62,7 +62,7 @@ public void FilterEntitiesWithContainsAndNotContains() var ids = new List { 1, 2, 3 }; var names = new List { "Chai", "Milk", "Water" }; Expression> filter = x => ids.Contains(x.ProductID) && !names.Contains(x.ProductName); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("(ProductID in (1,2,3)) and not (ProductName in ('Chai','Milk','Water'))"); + Assert.Equal("(ProductID in (1,2,3)) and not (ProductName in ('Chai','Milk','Water'))", ODataExpression.FromLinqExpression(filter).AsString(_session)); } } @@ -144,42 +144,42 @@ internal class TestEntity public void And() { Expression> filter = x => x.ProductID == 1 && x.ProductName == "Chai"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID eq 1 and ProductName eq 'Chai'"); + Assert.Equal("ProductID eq 1 and ProductName eq 'Chai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void Or() { Expression> filter = x => x.ProductName == "Chai" || x.ProductID == 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductName eq 'Chai' or ProductID eq 1"); + Assert.Equal("ProductName eq 'Chai' or ProductID eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void Not() { Expression> filter = x => !(x.ProductName == "Chai"); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("not (ProductName eq 'Chai')"); + Assert.Equal("not (ProductName eq 'Chai')", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void Precedence() { Expression> filter = x => (x.ProductID == 1 || x.ProductID == 2) && x.ProductName == "Chai"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("(ProductID eq 1 or ProductID eq 2) and ProductName eq 'Chai'"); + Assert.Equal("(ProductID eq 1 or ProductID eq 2) and ProductName eq 'Chai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualString() { Expression> filter = x => x.ProductName == "Chai"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductName eq 'Chai'"); + Assert.Equal("ProductName eq 'Chai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualFieldToString() { Expression> filter = x => x.ProductName.ToString() == "Chai"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductName eq 'Chai'"); + Assert.Equal("ProductName eq 'Chai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -187,112 +187,112 @@ public void EqualValueToString() { var name = "Chai"; Expression> filter = x => x.ProductName.ToString() == name.ToString(); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductName eq 'Chai'"); + Assert.Equal("ProductName eq 'Chai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualNumeric() { Expression> filter = x => x.ProductID == 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID eq 1"); + Assert.Equal("ProductID eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void NotEqualNumeric() { Expression> filter = x => x.ProductID != 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID ne 1"); + Assert.Equal("ProductID ne 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void GreaterNumeric() { Expression> filter = x => x.ProductID > 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID gt 1"); + Assert.Equal("ProductID gt 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void GreaterOrEqualNumeric() { Expression> filter = x => x.ProductID >= 1.5; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"ProductID ge 1.5{FormatSettings.DoubleNumberSuffix}"); + Assert.Equal($"ProductID ge 1.5{FormatSettings.DoubleNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void LessNumeric() { Expression> filter = x => x.ProductID < 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID lt 1"); + Assert.Equal("ProductID lt 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void LessOrEqualNumeric() { Expression> filter = x => x.ProductID <= 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID le 1"); + Assert.Equal("ProductID le 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void AddEqualNumeric() { Expression> filter = x => x.ProductID + 1 == 2; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID add 1 eq 2"); + Assert.Equal("ProductID add 1 eq 2", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void SubEqualNumeric() { Expression> filter = x => x.ProductID - 1 == 2; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID sub 1 eq 2"); + Assert.Equal("ProductID sub 1 eq 2", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void MulEqualNumeric() { Expression> filter = x => x.ProductID * 1 == 2; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID mul 1 eq 2"); + Assert.Equal("ProductID mul 1 eq 2", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void DivEqualNumeric() { Expression> filter = x => x.ProductID / 1 == 2; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID div 1 eq 2"); + Assert.Equal("ProductID div 1 eq 2", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void ModEqualNumeric() { Expression> filter = x => x.ProductID % 1 == 2; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("ProductID mod 1 eq 2"); + Assert.Equal("ProductID mod 1 eq 2", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualLong() { Expression> filter = x => x.ProductID == 1L; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"ProductID eq 1{FormatSettings.LongNumberSuffix}"); + Assert.Equal($"ProductID eq 1{FormatSettings.LongNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualDecimal() { Expression> filter = x => x.Price == 1M; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Price eq 1{FormatSettings.DecimalNumberSuffix}"); + Assert.Equal($"Price eq 1{FormatSettings.DecimalNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualDecimalWithFractionalPart() { Expression> filter = x => x.Price == 1.23M; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Price eq 1.23{FormatSettings.DecimalNumberSuffix}"); + Assert.Equal($"Price eq 1.23{FormatSettings.DecimalNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualGuid() { Expression> filter = x => x.LinkID == Guid.Empty; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"LinkID eq {FormatSettings.GetGuidFormat("00000000-0000-0000-0000-000000000000")}"); + Assert.Equal($"LinkID eq {FormatSettings.GetGuidFormat("00000000-0000-0000-0000-000000000000")}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -301,7 +301,7 @@ public void EqualDateTime() if (FormatSettings.ODataVersion < 4) { Expression> filter = x => x.CreationTime == new DateTime(2013, 1, 1); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("CreationTime eq datetime'2013-01-01T00:00:00'"); + Assert.Equal("CreationTime eq datetime'2013-01-01T00:00:00'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } } @@ -309,210 +309,210 @@ public void EqualDateTime() public void EqualDateTimeOffset() { Expression> filter = x => x.Updated == new DateTimeOffset(new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Updated eq {FormatSettings.GetDateTimeOffsetFormat("2013-01-01T00:00:00Z")}"); + Assert.Equal($"Updated eq {FormatSettings.GetDateTimeOffsetFormat("2013-01-01T00:00:00Z")}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualTimeSpan() { Expression> filter = x => x.Period == new TimeSpan(1, 2, 3); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Period eq {FormatSettings.TimeSpanPrefix}'PT1H2M3S'"); + Assert.Equal($"Period eq {FormatSettings.TimeSpanPrefix}'PT1H2M3S'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void LengthOfStringEqual() { Expression> filter = x => x.ProductName.Length == 4; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("length(ProductName) eq 4"); + Assert.Equal("length(ProductName) eq 4", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringToLowerEqual() { Expression> filter = x => x.ProductName.ToLower() == "chai"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("tolower(ProductName) eq 'chai'"); + Assert.Equal("tolower(ProductName) eq 'chai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringToUpperEqual() { Expression> filter = x => x.ProductName.ToUpper() == "CHAI"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("toupper(ProductName) eq 'CHAI'"); + Assert.Equal("toupper(ProductName) eq 'CHAI'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringStartsWithEqual() { Expression> filter = x => x.ProductName.StartsWith("Ch") == true; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("startswith(ProductName,'Ch') eq true"); + Assert.Equal("startswith(ProductName,'Ch') eq true", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringEndsWithEqual() { Expression> filter = x => x.ProductName.EndsWith("Ch") == true; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("endswith(ProductName,'Ch') eq true"); + Assert.Equal("endswith(ProductName,'Ch') eq true", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringContainsEqualTrue() { Expression> filter = x => x.ProductName.Contains("ai") == true; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"{FormatSettings.GetContainsFormat("ProductName", "ai")} eq true"); + Assert.Equal($"{FormatSettings.GetContainsFormat("ProductName", "ai")} eq true", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringContainsEqualFalse() { Expression> filter = x => x.ProductName.Contains("ai") == false; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"{FormatSettings.GetContainsFormat("ProductName", "ai")} eq false"); + Assert.Equal($"{FormatSettings.GetContainsFormat("ProductName", "ai")} eq false", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringContains() { Expression> filter = x => x.ProductName.Contains("ai"); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be(FormatSettings.GetContainsFormat("ProductName", "ai")); + Assert.Equal(FormatSettings.GetContainsFormat("ProductName", "ai"), ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringContainedIn() { Expression> filter = x => "Chai".Contains(x.ProductName); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be(FormatSettings.GetContainedInFormat("ProductName", "Chai")); + Assert.Equal(FormatSettings.GetContainedInFormat("ProductName", "Chai"), ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringNotContains() { Expression> filter = x => !x.ProductName.Contains("ai"); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"not {FormatSettings.GetContainsFormat("ProductName", "ai")}"); + Assert.Equal($"not {FormatSettings.GetContainsFormat("ProductName", "ai")}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void StringToLowerAndContains() { Expression> filter = x => x.ProductName.ToLower().Contains("Chai"); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be(FormatSettings.GetContainsFormat("tolower(ProductName)", "Chai")); + Assert.Equal(FormatSettings.GetContainsFormat("tolower(ProductName)", "Chai"), ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void IndexOfStringEqual() { Expression> filter = x => x.ProductName.IndexOf("ai") == 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("indexof(ProductName,'ai') eq 1"); + Assert.Equal("indexof(ProductName,'ai') eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void SubstringWithPositionEqual() { Expression> filter = x => x.ProductName.Substring(1) == "hai"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("substring(ProductName,1) eq 'hai'"); + Assert.Equal("substring(ProductName,1) eq 'hai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void SubstringWithPositionAndLengthEqual() { Expression> filter = x => x.ProductName.Substring(1, 2) == "ha"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("substring(ProductName,1,2) eq 'ha'"); + Assert.Equal("substring(ProductName,1,2) eq 'ha'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void ReplaceStringEqual() { Expression> filter = x => x.ProductName.Replace("a", "o") == "Choi"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("replace(ProductName,'a','o') eq 'Choi'"); + Assert.Equal("replace(ProductName,'a','o') eq 'Choi'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void TrimEqual() { Expression> filter = x => x.ProductName.Trim() == "Chai"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("trim(ProductName) eq 'Chai'"); + Assert.Equal("trim(ProductName) eq 'Chai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void ConcatEqual() { Expression> filter = x => string.Concat(x.ProductName, "Chai") == "ChaiChai"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("concat(ProductName,'Chai') eq 'ChaiChai'"); + Assert.Equal("concat(ProductName,'Chai') eq 'ChaiChai'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void DayEqual() { Expression> filter = x => x.CreationTime.Day == 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("day(CreationTime) eq 1"); + Assert.Equal("day(CreationTime) eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void MonthEqual() { Expression> filter = x => x.CreationTime.Month == 2; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("month(CreationTime) eq 2"); + Assert.Equal("month(CreationTime) eq 2", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void YearEqual() { Expression> filter = x => x.CreationTime.Year == 3; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("year(CreationTime) eq 3"); + Assert.Equal("year(CreationTime) eq 3", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void HourEqual() { Expression> filter = x => x.CreationTime.Hour == 4; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("hour(CreationTime) eq 4"); + Assert.Equal("hour(CreationTime) eq 4", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void MinuteEqual() { Expression> filter = x => x.CreationTime.Minute == 5; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("minute(CreationTime) eq 5"); + Assert.Equal("minute(CreationTime) eq 5", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void SecondEqual() { Expression> filter = x => x.CreationTime.Second == 6; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("second(CreationTime) eq 6"); + Assert.Equal("second(CreationTime) eq 6", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void RoundEqual() { Expression> filter = x => decimal.Round(x.Price) == 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"round(Price) eq 1{FormatSettings.DecimalNumberSuffix}"); + Assert.Equal($"round(Price) eq 1{FormatSettings.DecimalNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FloorEqual() { Expression> filter = x => decimal.Floor(x.Price) == 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"floor(Price) eq 1{FormatSettings.DecimalNumberSuffix}"); + Assert.Equal($"floor(Price) eq 1{FormatSettings.DecimalNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void CeilingEqual() { Expression> filter = x => decimal.Ceiling(x.Price) == 2; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"ceiling(Price) eq 2{FormatSettings.DecimalNumberSuffix}"); + Assert.Equal($"ceiling(Price) eq 2{FormatSettings.DecimalNumberSuffix}", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualNestedProperty() { Expression> filter = x => x.Nested.ProductID == 1; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Nested/ProductID eq 1"); + Assert.Equal("Nested/ProductID eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void EqualNestedPropertyLengthOfStringEqual() { Expression> filter = x => x.Nested.ProductName.Length == 4; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("length(Nested/ProductName) eq 4"); + Assert.Equal("length(Nested/ProductName) eq 4", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -520,63 +520,64 @@ public void ConvertEqual() { var id = "1"; Expression> filter = x => x.Nested.ProductID == Convert.ToInt32(id); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Nested/ProductID eq 1"); + Assert.Equal("Nested/ProductID eq 1", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithMappedPropertiesUsingColumnAttribute() { Expression> filter = x => x.MappedNameUsingColumnAttribute == "Milk"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Milk'"); + Assert.Equal("Name eq 'Milk'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithMappedPropertiesUsingDataAttribute() { Expression> filter = x => x.MappedNameUsingDataAttribute == "Milk"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Milk'"); + Assert.Equal("Name eq 'Milk'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithMappedPropertiesUsingDataMemberAttribute() { Expression> filter = x => x.MappedNameUsingDataMemberAttribute == "Milk"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Milk'"); + Assert.Equal("Name eq 'Milk'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithMappedPropertiesUsingOtherAttribute() { Expression> filter = x => x.MappedNameUsingOtherAttribute == "Milk"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Milk'"); + Assert.Equal("Name eq 'Milk'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithMappedPropertiesUsingDataMemberAndOtherAttribute() { Expression> filter = x => x.MappedNameUsingDataMemberAndOtherAttribute == "Milk"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Milk'"); + Assert.Equal("Name eq 'Milk'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithMappedPropertiesUsingJsonPropertyAttribute() { Expression> filter = x => x.MappedNameUsingJsonPropertyAttribute == "Milk"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Milk'"); + Assert.Equal("Name eq 'Milk'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithMappedPropertiesUsingJsonPropertyNameAttribute() { Expression> filter = x => x.MappedNameUsingJsonPropertyNameAttribute == "Milk"; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Milk'"); + Assert.Equal("Name eq 'Milk'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithEnum() { Expression> filter = x => x.Address.Type == AddressType.Corporate; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}"); + Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -584,7 +585,8 @@ public void FilterWithEnum_LocalVar() { var addressType = AddressType.Corporate; Expression> filter = x => x.Address.Type == addressType; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}"); + Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } private readonly AddressType addressType = AddressType.Corporate; @@ -593,7 +595,8 @@ public void FilterWithEnum_LocalVar() public void FilterWithEnum_MemberVar() { Expression> filter = x => x.Address.Type == addressType; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}"); + Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -601,7 +604,8 @@ public void FilterWithEnum_Const() { const AddressType addressType = AddressType.Corporate; Expression> filter = x => x.Address.Type == addressType; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}"); + Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -612,7 +616,8 @@ public void FilterWithEnum_PrefixFree() try { Expression> filter = x => x.Address.Type == AddressType.Corporate; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel", true)}"); + Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel", true)}", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } finally { @@ -624,14 +629,16 @@ public void FilterWithEnum_PrefixFree() public void FilterWithEnum_HasFlag() { Expression> filter = x => x.Address.Type.HasFlag(AddressType.Corporate); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Address/Type has {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}"); + Assert.Equal($"Address/Type has {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] public void FilterWithEnum_ToString() { Expression> filter = x => x.Address.Type.ToString() == AddressType.Corporate.ToString(); - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}"); + Assert.Equal($"Address/Type eq {FormatSettings.GetEnumFormat(AddressType.Corporate, typeof(AddressType), "NorthwindModel")}", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } [Fact] @@ -642,11 +649,13 @@ public void FilterDateTimeRange() Expression> filter = x => (x.CreationTime >= beforeDT) && (x.CreationTime < afterDT); if (FormatSettings.ODataVersion < 4) { - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("CreationTime ge datetime'2013-01-01T00:00:00Z' and CreationTime lt datetime'2014-02-02T00:00:00Z'"); + Assert.Equal("CreationTime ge datetime'2013-01-01T00:00:00Z' and CreationTime lt datetime'2014-02-02T00:00:00Z'", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } else { - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("CreationTime ge 2013-01-01T00:00:00Z and CreationTime lt 2014-02-02T00:00:00Z"); + Assert.Equal("CreationTime ge 2013-01-01T00:00:00Z and CreationTime lt 2014-02-02T00:00:00Z", + ODataExpression.FromLinqExpression(filter).AsString(_session)); } } @@ -657,7 +666,7 @@ public void ExpressionBuilder() Expression> condition2 = x => x.ProductID == 1; var filter = new ODataExpression(condition1); filter = filter || new ODataExpression(condition2); - filter.AsString(_session).Should().Be("ProductName eq 'Chai' or ProductID eq 1"); + Assert.Equal("ProductName eq 'Chai' or ProductID eq 1", filter.AsString(_session)); } [Fact] @@ -665,7 +674,7 @@ public void ExpressionBuilderGeneric() { var filter = new ODataExpression(x => x.ProductName == "Chai"); filter = filter || new ODataExpression(x => x.ProductID == 1); - filter.AsString(_session).Should().Be("ProductName eq 'Chai' or ProductID eq 1"); + Assert.Equal("ProductName eq 'Chai' or ProductID eq 1", filter.AsString(_session)); } [Fact] @@ -678,7 +687,7 @@ public void ExpressionBuilderGrouping() var filter1 = new ODataExpression(condition1) || new ODataExpression(condition2); var filter2 = new ODataExpression(condition3) || new ODataExpression(condition4); var filter = filter1 && filter2; - filter.AsString(_session).Should().Be("(ProductName eq 'Chai' or ProductID eq 1) and (ProductName eq 'Kaffe' or ProductID eq 2)"); + Assert.Equal("(ProductName eq 'Chai' or ProductID eq 1) and (ProductName eq 'Kaffe' or ProductID eq 2)", filter.AsString(_session)); } [Fact] @@ -689,14 +698,14 @@ public void FilterEqualityToMappedPropertyOfOtherEntity() MappedNameUsingDataMemberAttribute = "Other Name" }; Expression> filter = x => x.MappedNameUsingDataMemberAttribute == otherEntity.MappedNameUsingDataMemberAttribute; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Other Name'"); + Assert.Equal("Name eq 'Other Name'", ODataExpression.FromLinqExpression(filter).AsString(_session)); otherEntity = new TestEntity { MappedNameUsingJsonPropertyAttribute = "Other Name" }; filter = x => x.MappedNameUsingJsonPropertyAttribute == otherEntity.MappedNameUsingJsonPropertyAttribute; - ODataExpression.FromLinqExpression(filter).AsString(_session).Should().Be("Name eq 'Other Name'"); + Assert.Equal("Name eq 'Other Name'", ODataExpression.FromLinqExpression(filter).AsString(_session)); } } diff --git a/src/Simple.OData.Client.UnitTests/Core/TypedFilterAsKeyTests.cs b/src/Simple.OData.Client.UnitTests/Core/TypedFilterAsKeyTests.cs index 8c857fb4..7f41d14c 100644 --- a/src/Simple.OData.Client.UnitTests/Core/TypedFilterAsKeyTests.cs +++ b/src/Simple.OData.Client.UnitTests/Core/TypedFilterAsKeyTests.cs @@ -44,7 +44,7 @@ public async Task FindAllByFilterWithContains() .For() .Filter(x => ids.Contains(x.ProductID)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$filter=%28ProductID%20in%20%281%2C2%2C3%29%29"); + Assert.Equal("Products?$filter=%28ProductID%20in%20%281%2C2%2C3%29%29", commandText); } } @@ -57,7 +57,7 @@ public async Task FindAllByTypedFilterAsKeyEqual() .For() .Filter(x => x.ProductID == 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products(1)"); + Assert.Equal("Products(1)", commandText); } [Fact] @@ -67,7 +67,7 @@ public async Task FindAllByFilterAsKeyNotEqual() .For() .Filter(x => x.ProductID != 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$filter=ProductID%20ne%201"); + Assert.Equal("Products?$filter=ProductID%20ne%201", commandText); } [Fact] @@ -78,7 +78,7 @@ public async Task FindAllByFilterTwoClauses() .Filter(x => x.ProductID != 1) .Filter(x => x.ProductID != 2); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$filter=ProductID%20ne%201%20and%20ProductID%20ne%202"); + Assert.Equal("Products?$filter=ProductID%20ne%201%20and%20ProductID%20ne%202", commandText); } [Fact] @@ -89,7 +89,7 @@ public async Task FindAllByFilterTwoClausesWithOr() .Filter(x => x.ProductID != 1 || x.ProductID != 2) .Filter(x => x.ProductID != 3); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$filter=%28ProductID%20ne%201%20or%20ProductID%20ne%202%29%20and%20ProductID%20ne%203"); + Assert.Equal("Products?$filter=%28ProductID%20ne%201%20or%20ProductID%20ne%202%29%20and%20ProductID%20ne%203", commandText); } [Fact] @@ -99,7 +99,7 @@ public async Task FindAllByFilterAsNotKeyEqual() .For() .Filter(x => !(x.ProductID == 1)); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be($"Products?$filter=not%20{Uri.EscapeDataString("(")}ProductID%20eq%201{Uri.EscapeDataString(")")}"); + Assert.Equal($"Products?$filter=not%20{Uri.EscapeDataString("(")}ProductID%20eq%201{Uri.EscapeDataString(")")}", commandText); } [Fact] @@ -109,7 +109,7 @@ public async Task FindAllByFilterAsKeyEqualLong() .For() .Filter(x => x.ProductID == 1L); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be($"Products(1{FormatSettings.LongNumberSuffix})"); + Assert.Equal($"Products(1{FormatSettings.LongNumberSuffix})", commandText); } [Fact] @@ -119,8 +119,8 @@ public async Task FindAllByFilterAsKeyEqualAndExtraClause() .For() .Filter(x => x.ProductID == 1 && x.ProductName == "abc"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be(string.Format("Products?$filter=ProductID%20eq%201%20and%20ProductName%20eq%20{0}abc{0}", - Uri.EscapeDataString("'"))); + Assert.Equal(string.Format("Products?$filter=ProductID%20eq%201%20and%20ProductName%20eq%20{0}abc{0}", + Uri.EscapeDataString("'")), commandText); } [Fact] @@ -132,7 +132,7 @@ public async Task FindAllByFilterAsFirstPartOfCompoundKeyEqualAndExtraClause() var commandText = await command.GetCommandTextAsync(); var expected = "Order_Details?$filter=OrderID%20eq%201%20and%20Quantity%20eq%201"; - commandText.Should().Be(expected); + Assert.Equal(expected, commandText); } [Fact] @@ -144,7 +144,7 @@ public async Task FindAllByFilterAsSecondPartOfCompoundKeyEqualAndExtraClause() var commandText = await command.GetCommandTextAsync(); var expected = "Order_Details?$filter=ProductID%20eq%201%20and%20Quantity%20eq%201"; - commandText.Should().Be(expected); + Assert.Equal(expected, commandText); } [Fact] @@ -154,7 +154,7 @@ public async Task FindAllByFilterAsKeyEqualDuplicateClause() .For() .Filter(x => x.ProductID == 1 && x.ProductID == 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products(1)"); + Assert.Equal("Products(1)", commandText); } [Fact] @@ -164,7 +164,7 @@ public async Task FindAllByFilterAsCompleteCompoundKey() .For() .Filter(x => x.OrderID == 1 && x.ProductID == 2); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Order_Details(OrderID=1,ProductID=2)"); + Assert.Equal("Order_Details(OrderID=1,ProductID=2)", commandText); } [Fact] @@ -174,7 +174,7 @@ public async Task FindAllByFilterAsInCompleteCompoundKey() .For() .Filter(x => x.OrderID == 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Order_Details?$filter=OrderID%20eq%201"); + Assert.Equal("Order_Details?$filter=OrderID%20eq%201", commandText); } [Fact] @@ -185,7 +185,7 @@ public async Task FindAllByFilterWithDateTimeOffset() .For() .Filter(x => x.ShippedDateTimeOffset > created); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}"); + Assert.Equal($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}", commandText); } [Fact] @@ -196,7 +196,7 @@ public async Task FindAllByFilterWithDateTimeOffsetCastFromDateTime() .For() .Filter(x => x.ShippedDateTimeOffset > created); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}"); + Assert.Equal($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}", commandText); } [Fact] @@ -207,7 +207,7 @@ public async Task FindAllByFilterWithDateTimeOffsetCastFromDateTimeOffset() .For() .Filter(x => x.ShippedDateTimeOffset > created); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}"); + Assert.Equal($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}", commandText); } [Fact] @@ -218,7 +218,7 @@ public async Task FindAllEmployeeSuperiors() .Filter(x => x.EmployeeID == 1) .NavigateTo("Superior"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Employees(1)/Superior"); + Assert.Equal("Employees(1)/Superior", commandText); } [Fact] @@ -229,7 +229,7 @@ public async Task FindAllCustomerOrders() .Filter(x => x.CustomerID == "ALFKI") .NavigateTo(); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Customers(%27ALFKI%27)/Orders"); + Assert.Equal("Customers(%27ALFKI%27)/Orders", commandText); } [Fact] @@ -240,7 +240,7 @@ public async Task FindAllEmployeeSubordinates() .Filter(x => x.EmployeeID == 2) .NavigateTo("Subordinates"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Employees(2)/Subordinates"); + Assert.Equal("Employees(2)/Subordinates", commandText); } [Fact] @@ -251,7 +251,7 @@ public async Task FindAllOrderOrderDetails() .Filter(x => x.OrderID == 10952) .NavigateTo(); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Orders(10952)/Order_Details"); + Assert.Equal("Orders(10952)/Order_Details", commandText); } [Fact] @@ -262,7 +262,7 @@ public async Task FindEmployeeSuperior() .Filter(x => x.EmployeeID == 1) .NavigateTo("Superior"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Employees(1)/Superior"); + Assert.Equal("Employees(1)/Superior", commandText); } [Fact] @@ -272,7 +272,7 @@ public async Task FindAllFromBaseTableByFilterAsKeyEqual() .For() .Filter(x => x.TransportID == 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Transport(1)"); + Assert.Equal("Transport(1)", commandText); } [Fact] @@ -283,7 +283,7 @@ public async Task FindAllFromDerivedTableByFilterAsKeyEqual() .As() .Filter(x => x.TransportID == 1); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Transport(1)/NorthwindModel.Ships"); + Assert.Equal("Transport(1)/NorthwindModel.Ships", commandText); } [Fact] @@ -294,7 +294,7 @@ public async Task FindAllByTypedFilterAndTypedQueryOptions() .Filter(x => x.ProductName == "abc") .QueryOptions(y => y.IntOption == 42 && y.StringOption == "xyz"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$filter=ProductName%20eq%20%27abc%27&IntOption=42&StringOption='xyz'"); + Assert.Equal("Products?$filter=ProductName%20eq%20%27abc%27&IntOption=42&StringOption='xyz'", commandText); } [Fact] @@ -305,7 +305,7 @@ public async Task FindAllByTypedFilterAndUntypedQueryOptions() .Filter(x => x.ProductName == "abc") .QueryOptions(new Dictionary() { { "IntOption", 42 }, { "StringOption", "xyz" } }); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Products?$filter=ProductName%20eq%20%27abc%27&IntOption=42&StringOption='xyz'"); + Assert.Equal("Products?$filter=ProductName%20eq%20%27abc%27&IntOption=42&StringOption='xyz'", commandText); } [Fact(Skip = "Revise URL escape method")] @@ -315,7 +315,7 @@ public async Task FindByStringKeyWithSpaceAndPunctuation() .For() .Key("CRONUS USA, Inc."); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("'CRONUS%20USA%2C%20Inc.'"); + Assert.Equal("'CRONUS%20USA%2C%20Inc.'", commandText); } [Fact] @@ -326,7 +326,7 @@ public async Task FindByGuidFilterEqual() .For() .Filter(x => x.Key == key); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be($"TypeWithGuidKey({Uri.EscapeDataString(FormatSettings.GetGuidFormat(key.ToString()))})"); + Assert.Equal($"TypeWithGuidKey({Uri.EscapeDataString(FormatSettings.GetGuidFormat(key.ToString()))})", commandText); } [Fact] @@ -337,7 +337,7 @@ public async Task FindByGuidKey() .For() .Key(key); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be($"TypeWithGuidKey({Uri.EscapeDataString(FormatSettings.GetGuidFormat(key.ToString()))})"); + Assert.Equal($"TypeWithGuidKey({Uri.EscapeDataString(FormatSettings.GetGuidFormat(key.ToString()))})", commandText); } [Fact] @@ -347,7 +347,7 @@ public async Task FindAllEntityLowerCaseNoPrefix() .For("project1") .Key("abc"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("project1(%27abc%27)"); + Assert.Equal("project1(%27abc%27)", commandText); } [Fact(Skip = "Entity set names with multiple segments are not supported")] @@ -358,7 +358,7 @@ public async Task FindAllEntityLowerCaseWithPrefix() .For("project2") .Key("abc"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("project2(%27abc%27)"); + Assert.Equal("project2(%27abc%27)", commandText); } [Fact] @@ -369,6 +369,6 @@ public async Task FindAllByFilterAndKey() .Key(1) .Filter(x => x.CategoryName == "Beverages"); var commandText = await command.GetCommandTextAsync(); - commandText.Should().Be("Categories(1)?$filter=CategoryName%20eq%20%27Beverages%27"); + Assert.Equal("Categories(1)?$filter=CategoryName%20eq%20%27Beverages%27", commandText); } } diff --git a/src/Simple.OData.Client.UnitTests/Extensions/DictionaryExtensionsTests.cs b/src/Simple.OData.Client.UnitTests/Extensions/DictionaryExtensionsTests.cs index 96e690f9..f9ee238c 100644 --- a/src/Simple.OData.Client.UnitTests/Extensions/DictionaryExtensionsTests.cs +++ b/src/Simple.OData.Client.UnitTests/Extensions/DictionaryExtensionsTests.cs @@ -135,9 +135,9 @@ public void ToObjectPrivateSetter() }; var value = dict.ToObject(TypeCache); - value.StringProperty.Should().Be("a"); + Assert.Equal("a", value.StringProperty); Assert.Equal(1, value.IntProperty); - value.StringPropertyPrivateSetter.Should().Be("p"); + Assert.Equal("p", value.StringPropertyPrivateSetter); } [Fact] @@ -151,9 +151,9 @@ public void ToObjectField() }; var value = dict.ToObject(TypeCache); - value.StringProperty.Should().Be("a"); + Assert.Equal("a", value.StringProperty); Assert.Equal(1, value.IntProperty); - value.StringField.Should().BeNull(); + Assert.Null(value.StringField); } [Fact] @@ -167,11 +167,11 @@ public void ToObjectStringArray() }; var value = dict.ToObject(TypeCache); - value.StringProperty.Should().Be("a"); + Assert.Equal("a", value.StringProperty); Assert.Equal(1, value.IntProperty); for (var index = 0; index < 3; index++) { - value.StringArrayProperty[index].Should().Be((dict["StringArrayProperty"] as IList)[index]); + Assert.Equal((dict["StringArrayProperty"] as IList)[index], value.StringArrayProperty[index]); } } @@ -186,7 +186,7 @@ public void ToObjectIntArray() }; var value = dict.ToObject(TypeCache); - value.StringProperty.Should().Be("a"); + Assert.Equal("a", value.StringProperty); Assert.Equal(1, value.IntProperty); for (var index = 0; index < 3; index++) { @@ -205,7 +205,7 @@ public void ToObjectIntCollection() }; var value = dict.ToObject(TypeCache); - value.StringProperty.Should().Be("a"); + Assert.Equal("a", value.StringProperty); Assert.Equal(1, value.IntProperty); for (var index = 0; index < 3; index++) { @@ -224,9 +224,9 @@ public void ToObjectCompoundProperty() }; var value = dict.ToObject(TypeCache); - value.StringProperty.Should().Be("a"); + Assert.Equal("a", value.StringProperty); Assert.Equal(1, value.IntProperty); - value.CompoundProperty.StringProperty.Should().Be("z"); + Assert.Equal("z", value.CompoundProperty.StringProperty); Assert.Equal(0, value.CompoundProperty.IntProperty); } @@ -247,13 +247,13 @@ public void ToObjectCompoundCollectionProperty() }; var value = dict.ToObject(TypeCache); - value.StringProperty.Should().Be("a"); + Assert.Equal("a", value.StringProperty); Assert.Equal(1, value.IntProperty); for (var index = 0; index < 3; index++) { var kv = (dict["CompoundCollectionProperty"] as IList>)[index]; - value.CompoundCollectionProperty[index].StringProperty.Should().Be(kv["StringProperty"]); - value.CompoundCollectionProperty[index].IntProperty.Should().Be(kv["IntProperty"]); + Assert.Equal(kv["StringProperty"], value.CompoundCollectionProperty[index].StringProperty); + Assert.Equal(kv["IntProperty"], value.CompoundCollectionProperty[index].IntProperty); } } @@ -267,8 +267,8 @@ public void ToObjectODataEntry() }; var value = dict.ToObject(TypeCache); - value["StringProperty"].Should().Be("a"); - value["IntProperty"].Should().Be(1); + Assert.Equal("a", value["StringProperty"]); + Assert.Equal(1, value["IntProperty"]); } [Fact] @@ -375,9 +375,9 @@ public void ToObjectBaseType_SubType() var value = dict.ToObject(TypeCache); var ship = value as Ship; - ship.Should().NotBeNull(); + Assert.NotNull(ship); Assert.Equal(1, ship.TransportID); - ship.ShipName.Should().Be("Sloop John B"); + Assert.Equal("Sloop John B", ship.ShipName); } [Fact] @@ -406,6 +406,6 @@ public void ToObjectClassWithoutDefaultCtor() { "Data", new ClassNoDefaultConstructor("test") }, }; - (() => dict.ToObject(TypeCache)).Should().ThrowExactly(); + Assert.Throws(() => dict.ToObject(TypeCache)); } } diff --git a/src/Simple.OData.Client.UnitTests/Extensions/TypeCacheTests.cs b/src/Simple.OData.Client.UnitTests/Extensions/TypeCacheTests.cs index da9279c2..d99f142e 100644 --- a/src/Simple.OData.Client.UnitTests/Extensions/TypeCacheTests.cs +++ b/src/Simple.OData.Client.UnitTests/Extensions/TypeCacheTests.cs @@ -53,19 +53,19 @@ public void GetNamedProperty_BaseType() public void GetNamedProperty_DerivedType() { TypeCache.GetNamedProperty(typeof(Ship), "TransportID").Should().NotBeNull(); - TypeCache.GetNamedProperty(typeof(Ship), "ShipName").Should().NotBeNull(); + Assert.NotNull(TypeCache.GetNamedProperty(typeof(Ship), "ShipName")); } [Fact] public void GetDeclaredProperty_BaseType() { - TypeCache.GetDeclaredProperty(typeof(Transport), "TransportID").Should().NotBeNull(); + Assert.NotNull(TypeCache.GetDeclaredProperty(typeof(Transport), "TransportID")); } [Fact] public void GetDeclaredProperty_DerivedType() { - TypeCache.GetDeclaredProperty(typeof(Ship), "TransportID").Should().BeNull(); - TypeCache.GetDeclaredProperty(typeof(Ship), "ShipName").Should().NotBeNull(); + Assert.Null(TypeCache.GetDeclaredProperty(typeof(Ship), "TransportID")); + Assert.NotNull(TypeCache.GetDeclaredProperty(typeof(Ship), "ShipName")); } } diff --git a/src/Simple.OData.Client.UnitTests/Extensions/TypeExtensionTests.cs b/src/Simple.OData.Client.UnitTests/Extensions/TypeExtensionTests.cs index 7375d035..34b0da21 100644 --- a/src/Simple.OData.Client.UnitTests/Extensions/TypeExtensionTests.cs +++ b/src/Simple.OData.Client.UnitTests/Extensions/TypeExtensionTests.cs @@ -52,19 +52,19 @@ public void GetNamedProperty_BaseType() public void GetNamedProperty_DerivedType() { typeof(Ship).GetNamedProperty("TransportID").Should().NotBeNull(); - typeof(Ship).GetNamedProperty("ShipName").Should().NotBeNull(); + Assert.NotNull(typeof(Ship).GetNamedProperty("ShipName")); } [Fact] public void GetDeclaredProperty_BaseType() { - typeof(Transport).GetDeclaredProperty("TransportID").Should().NotBeNull(); + Assert.NotNull(typeof(Transport).GetDeclaredProperty("TransportID")); } [Fact] public void GetDeclaredProperty_DerivedType() { - typeof(Ship).GetDeclaredProperty("TransportID").Should().BeNull(); - typeof(Ship).GetDeclaredProperty("ShipName").Should().NotBeNull(); + Assert.Null(typeof(Ship).GetDeclaredProperty("TransportID")); + Assert.NotNull(typeof(Ship).GetDeclaredProperty("ShipName")); } } diff --git a/src/Simple.OData.Client.UnitTests/Extensions/XElementExtensionsTests.cs b/src/Simple.OData.Client.UnitTests/Extensions/XElementExtensionsTests.cs index ca8afb12..55bc4ca4 100644 --- a/src/Simple.OData.Client.UnitTests/Extensions/XElementExtensionsTests.cs +++ b/src/Simple.OData.Client.UnitTests/Extensions/XElementExtensionsTests.cs @@ -26,8 +26,8 @@ public void TestXElementWithNoNamespace() var element = XElement.Parse(content); var list = element.Elements(null, "child").ToList(); Assert.Equal(2, list.Count); - list[0].Element(null, "sub").Value.Should().Be("Foo"); - list[1].Element(null, "sub").Value.Should().Be("Bar"); + Assert.Equal("Foo", list[0].Element(null, "sub").Value); + Assert.Equal("Bar", list[1].Element(null, "sub").Value); } [Fact] @@ -37,7 +37,7 @@ public void TestXElementWithPrefixedNamespace() var element = XElement.Parse(content); var list = element.Elements("c", "child").ToList(); Assert.Equal(2, list.Count); - list[0].Element("c", "sub").Value.Should().Be("Foo"); - list[1].Element("c", "sub").Value.Should().Be("Bar"); + Assert.Equal("Foo", list[0].Element("c", "sub").Value); + Assert.Equal("Bar", list[1].Element("c", "sub").Value); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/BatchTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/BatchTests.cs index 4e94c2e4..cefa4959 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/BatchTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/BatchTests.cs @@ -40,7 +40,7 @@ public async Task ReadOnlyBatch() batch += async c => product = await c.FindEntryAsync("Products"); await batch.ExecuteAsync(); - product.Should().NotBeNull(); + Assert.NotNull(product); } [Fact] @@ -60,13 +60,13 @@ public async Task NestedBatch() var client = new ODataClient(settings); var product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test1'"); - product.Should().NotBeNull(); + Assert.NotNull(product); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test2'"); - product.Should().NotBeNull(); + Assert.NotNull(product); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test3'"); - product.Should().NotBeNull(); + Assert.NotNull(product); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test4'"); - product.Should().NotBeNull(); + Assert.NotNull(product); } [Fact] @@ -81,14 +81,14 @@ public async Task SuccessWithResults() batch += async x => { product2 = await x.InsertEntryAsync("Products", new Entry() { { "ProductName", "Test2" }, { "UnitPrice", 20m } }); }; await batch.ExecuteAsync(); - product1["ProductID"].Should().NotBeNull(); - product2["ProductID"].Should().NotBeNull(); + Assert.NotNull(product1["ProductID"]); + Assert.NotNull(product2["ProductID"]); var client = new ODataClient(settings); product1 = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test1'"); - product1.Should().NotBeNull(); + Assert.NotNull(product1); product2 = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test2'"); - product2.Should().NotBeNull(); + Assert.NotNull(product2); } [Fact] @@ -105,7 +105,7 @@ public async Task PartialFailures() } catch (WebRequestException exception) { - exception.Response.Should().NotBeNull(); + Assert.NotNull(exception.Response); } } @@ -123,7 +123,7 @@ public async Task AllFailures() } catch (WebRequestException exception) { - exception.Response.Should().NotBeNull(); + Assert.NotNull(exception.Response); } } @@ -146,12 +146,12 @@ public async Task MultipleUpdateEntrySingleBatch() batch += async x => product2 = await x.FindEntryAsync("Products?$filter=ProductName eq 'Test11'"); await batch.ExecuteAsync(); - product1["UnitPrice"].Should().Be(22m); - product2["UnitPrice"].Should().Be(23m); + Assert.Equal(22m, product1["UnitPrice"]); + Assert.Equal(23m, product2["UnitPrice"]); var client = new ODataClient(settings); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test11'"); - product["UnitPrice"].Should().Be(23m); + Assert.Equal(23m, product["UnitPrice"]); } [Fact] @@ -172,7 +172,7 @@ public async Task MultipleUpdatesEntriesSingleBatch() var client = new ODataClient(settings); product = await client.FindEntryAsync("Products?$filter=UnitPrice eq 121"); - product.Should().BeNull(); + Assert.Null(product); var products = await client.FindEntriesAsync("Products?$filter=UnitPrice eq 122"); Assert.Equal(3, products.Count()); } @@ -196,12 +196,12 @@ public async Task UpdateDeleteSingleBatch() batch += async c => product2 = await c.FindEntryAsync("Products?$filter=ProductName eq 'Test11'"); await batch.ExecuteAsync(); - product1["UnitPrice"].Should().Be(22m); - product2.Should().BeNull(); + Assert.Equal(22m, product1["UnitPrice"]); + Assert.Null(product2); var client = new ODataClient(settings); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test11'"); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -214,7 +214,7 @@ public async Task InsertUpdateDeleteSeparateBatches() var client = new ODataClient(settings); var product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test12'"); - product["UnitPrice"].Should().Be(21m); + Assert.Equal(21m, product["UnitPrice"]); var key = new Entry() { { "ProductID", product["ProductID"] } }; batch = new ODataBatch(settings); @@ -222,14 +222,14 @@ public async Task InsertUpdateDeleteSeparateBatches() await batch.ExecuteAsync(); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test12'"); - product["UnitPrice"].Should().Be(22m); + Assert.Equal(22m, product["UnitPrice"]); batch = new ODataBatch(settings); batch += c => c.DeleteEntryAsync("Products", key); await batch.ExecuteAsync(); product = await client.FindEntryAsync("Products?$filter=ProductName eq 'Test12'"); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -248,7 +248,7 @@ public async Task InsertSingleEntityWithSingleAssociationSingleBatch() .Expand("Category") .Filter("ProductName eq 'Test14'") .FindEntryAsync(); - (product["Category"] as IDictionary)["CategoryName"].Should().Be("Test13"); + Assert.Equal("Test13", (product["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -298,7 +298,7 @@ public async Task DeleteEntriesExisting() .For("Products") .Filter("ProductName eq 'Test19'") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -329,7 +329,7 @@ public async Task DeleteEntriesMultiple() .For("Products") .Filter("UnitPrice eq 111") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -359,7 +359,7 @@ public async Task UpdateWithResultRequired() batch += async c => product1 = await c.UpdateEntryAsync("Products", product, new Entry() { { "UnitPrice", 22m } }, true); await batch.ExecuteAsync(); - product1["UnitPrice"].Should().Be(22m); + Assert.Equal(22m, product1["UnitPrice"]); } [Fact] @@ -402,8 +402,8 @@ public async Task LinkEntry(bool useAbsoluteReferenceUris) .For("Products") .Filter("ProductName eq 'Test5'") .FindEntryAsync(); - product["CategoryID"].Should().NotBeNull(); - product["CategoryID"].Should().Be(category["CategoryID"]); + Assert.NotNull(product["CategoryID"]); + Assert.Equal(category["CategoryID"], product["CategoryID"]); } [Fact] @@ -436,6 +436,6 @@ public async Task WithHttpHeaders() await batch.ExecuteAsync(); - (headers.TryGetValue("batchHeader", out var value) && value == "batchHeaderValue").Should().BeTrue(); + Assert.True(headers.TryGetValue("batchHeader", out var value) && value == "batchHeaderValue"); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/BatchTypedTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/BatchTypedTests.cs index 27e259a3..fe0580ff 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/BatchTypedTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/BatchTypedTests.cs @@ -59,12 +59,12 @@ public async Task SuccessWithResults() .For() .Filter(x => x.ProductName == "Test1") .FindEntryAsync(); - product1.Should().NotBeNull(); + Assert.NotNull(product1); product2 = await client .For() .Filter(x => x.ProductName == "Test2") .FindEntryAsync(); - product2.Should().NotBeNull(); + Assert.NotNull(product2); } [Fact] @@ -87,7 +87,7 @@ public async Task PartialFailures() } catch (WebRequestException exception) { - exception.Response.Should().NotBeNull(); + Assert.NotNull(exception.Response); } } @@ -111,7 +111,7 @@ public async Task AllFailures() } catch (WebRequestException exception) { - exception.Response.Should().NotBeNull(); + Assert.NotNull(exception.Response); } } @@ -198,14 +198,14 @@ public async Task UpdateDeleteSingleBatch() await batch.ExecuteAsync(); Assert.Equal(22m, product1.UnitPrice); - product2.Should().BeNull(); + Assert.Null(product2); var client = new ODataClient(settings); product = await client .For() .Filter(x => x.ProductName == "Test11") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -252,7 +252,7 @@ public async Task InsertUpdateDeleteSeparateBatches() .For() .Filter(x => x.ProductName == "Test12") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -277,7 +277,7 @@ public async Task InsertSingleEntityWithSingleAssociationSingleBatch() .Expand(x => x.Category) .Filter(x => x.ProductName == "Test14") .FindEntryAsync(); - product.Category.CategoryName.Should().Be("Test13"); + Assert.Equal("Test13", product.Category.CategoryName); } [Fact] diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/DeleteTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/DeleteTests.cs index 72423acf..29badaaa 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/DeleteTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/DeleteTests.cs @@ -69,7 +69,7 @@ await client .Filter("ProductName eq 'Test1'") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -94,7 +94,7 @@ await client .Filter("ProductName eq 'Test1'") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -116,7 +116,7 @@ await client .Filter("ProductName eq 'Test1'") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -141,6 +141,6 @@ await client .Filter("ShipName eq 'Test1'") .FindEntryAsync(); - ship.Should().BeNull(); + Assert.Null(ship); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/DeleteTypedTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/DeleteTypedTests.cs index 57a93d5d..8562005b 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/DeleteTypedTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/DeleteTypedTests.cs @@ -68,7 +68,7 @@ await client .Filter(x => x.ProductName == "Test1") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } [Fact] @@ -93,6 +93,6 @@ await client .Filter(x => x.ShipName == "Test1") .FindEntryAsync(); - ship.Should().BeNull(); + Assert.Null(ship); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/FindDynamicTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/FindDynamicTests.cs index 602a26c8..e287df98 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/FindDynamicTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/FindDynamicTests.cs @@ -462,7 +462,7 @@ public async Task AllDerivedClassEntriesWithAnnotations() .As(x.Ships) .FindEntriesAsync(); Assert.Equal("Titanic", (transport as IEnumerable).Single().ShipName); - ((transport as IEnumerable).Single()[FluentCommand.AnnotationsLiteral] as ODataEntryAnnotations).TypeName.Should().Be("NorthwindModel.Ship"); + Assert.Equal("NorthwindModel.Ship", ((transport as IEnumerable).Single()[FluentCommand.AnnotationsLiteral] as ODataEntryAnnotations).TypeName); } [Fact] @@ -609,7 +609,7 @@ public async Task ImplicitCastToType() .For(x.Products) .Filter(x.ProductName == "Chai") .FindEntryAsync(); - product.ProductName.Should().Be("Chai"); + Assert.Equal("Chai", product.ProductName); } [Fact] @@ -621,6 +621,6 @@ public async Task ImplicitCastToTypeNullResult() .For(x.Products) .Filter(x.ProductName == "XYZ") .FindEntryAsync(); - product.Should().BeNull(); + Assert.Null(product); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/FindTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/FindTests.cs index b6fe4116..fa03b680 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/FindTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/FindTests.cs @@ -41,7 +41,7 @@ public async Task Get() .For("Categories") .Key(1) .FindEntryAsync(); - category["CategoryID"].Should().Be(1); + Assert.Equal(1, category["CategoryID"]); } [Fact] @@ -96,7 +96,7 @@ public async Task OrderBy() .For("Products") .OrderBy("ProductName") .FindEntriesAsync()).First(); - product["ProductName"].Should().Be("Alice Mutton"); + Assert.Equal("Alice Mutton", product["ProductName"]); } [Fact] @@ -107,7 +107,7 @@ public async Task OrderByDescending() .For("Products") .OrderByDescending("ProductName") .FindEntriesAsync()).First(); - product["ProductName"].Should().Be("Zaanse koeken"); + Assert.Equal("Zaanse koeken", product["ProductName"]); } [Fact] @@ -119,7 +119,7 @@ public async Task OrderByExpanded() .Expand("Category") .OrderBy("Category/CategoryName") .FindEntriesAsync()).Last(); - (product["Category"] as IDictionary)["CategoryName"].Should().Be("Seafood"); + Assert.Equal("Seafood", (product["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -130,8 +130,8 @@ public async Task SelectSingle() .For("Products") .Select("ProductName") .FindEntryAsync(); - product.Keys.Should().Contain("ProductName"); - product.Keys.Should().NotContain("ProductID"); + Assert.Contains("ProductName", product.Keys); + Assert.DoesNotContain("ProductID", product.Keys); } [Fact] @@ -142,8 +142,8 @@ public async Task SelectSingleHomogenize() .For("Products") .Select("Product_Name") .FindEntryAsync(); - product.Keys.Should().Contain("ProductName"); - product.Keys.Should().NotContain("ProductID"); + Assert.Contains("ProductName", product.Keys); + Assert.DoesNotContain("ProductID", product.Keys); } [Fact] @@ -154,8 +154,8 @@ public async Task SelectMultiple() .For("Products") .Select("ProductID", "ProductName") .FindEntryAsync(); - product.Keys.Should().Contain("ProductName"); - product.Keys.Should().Contain("ProductID"); + Assert.Contains("ProductName", product.Keys); + Assert.Contains("ProductID", product.Keys); } [Fact] @@ -167,8 +167,8 @@ public async Task SelectMultipleSingleString() .Select("ProductID, ProductName") .FindEntryAsync(); Assert.Equal(2, product.Count); - product.Keys.Should().Contain("ProductName"); - product.Keys.Should().Contain("ProductID"); + Assert.Contains("ProductName", product.Keys); + Assert.Contains("ProductID", product.Keys); } [Fact] @@ -180,7 +180,7 @@ public async Task ExpandOne() .OrderBy("ProductID") .Expand("Category") .FindEntriesAsync()).Last(); - (product["Category"] as IDictionary)["CategoryName"].Should().Be("Condiments"); + Assert.Equal("Condiments", (product["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -216,8 +216,8 @@ public async Task ExpandMultipleLevelsWithCollection() .OrderBy("ProductID") .Expand("Category/Products/Category") .FindEntriesAsync()).Last(); - ((((product["Category"] as IDictionary)["Products"] as IEnumerable) - .First() as IDictionary)["Category"] as IDictionary)["CategoryName"].Should().Be("Condiments"); + Assert.Equal("Condiments", ((((product["Category"] as IDictionary)["Products"] as IEnumerable) + .First() as IDictionary)["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -236,8 +236,8 @@ public async Task ExpandMultipleLevelsWithCollectionAndSelect() .First() as IDictionary).Count); Assert.Equal(1, ((((product["Category"] as IDictionary)["Products"] as IEnumerable) .First() as IDictionary)["Category"] as IDictionary).Count); - ((((product["Category"] as IDictionary)["Products"] as IEnumerable) - .First() as IDictionary)["Category"] as IDictionary)["CategoryName"].Should().Be("Condiments"); + Assert.Equal("Condiments", ((((product["Category"] as IDictionary)["Products"] as IEnumerable) + .First() as IDictionary)["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -252,7 +252,7 @@ public async Task ExpandWithSelect() .FindEntriesAsync()).Last(); Assert.Equal(2, product.Count); Assert.Equal(1, (product["Category"] as IDictionary).Count); - (product["Category"] as IDictionary)["CategoryName"].Should().Be("Condiments"); + Assert.Equal("Condiments", (product["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -302,7 +302,7 @@ public async Task CombineAll() .Expand("Category") .Select("Category") .FindEntriesAsync()).Single(); - (product["Category"] as IDictionary)["CategoryName"].Should().Be("Seafood"); + Assert.Equal("Seafood", (product["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -317,7 +317,7 @@ public async Task CombineAllReverse() .Skip(2) .OrderBy("ProductName") .FindEntriesAsync()).Single(); - (product["Category"] as IDictionary)["CategoryName"].Should().Be("Seafood"); + Assert.Equal("Seafood", (product["Category"] as IDictionary)["CategoryName"]); } [Fact] @@ -329,7 +329,7 @@ public async Task NavigateToSingle() .Key(new Entry() { { "ProductID", 2 } }) .NavigateTo("Category") .FindEntryAsync(); - category["CategoryName"].Should().Be("Beverages"); + Assert.Equal("Beverages", category["CategoryName"]); } [Fact] @@ -356,7 +356,7 @@ public async Task NavigateToRecursive() .NavigateTo("Subordinates") .Key(3) .FindEntryAsync(); - employee["FirstName"].Should().Be("Janet"); + Assert.Equal("Janet", employee["FirstName"]); } [Fact] @@ -369,7 +369,7 @@ public async Task NavigateToRecursiveSingleClause() .NavigateTo("Superior/Superior/Subordinates") .Key(3) .FindEntryAsync(); - employee["FirstName"].Should().Be("Janet"); + Assert.Equal("Janet", employee["FirstName"]); } [Fact] @@ -380,7 +380,7 @@ public async Task BaseClassEntries() .For("Transport") .FindEntriesAsync(); Assert.Equal(2, transport.Count()); - (x => x.ContainsKey(FluentCommand.AnnotationsLiteral)).Should().NotContain(transport); + Assert.DoesNotContain(transport, x => x.ContainsKey(FluentCommand.AnnotationsLiteral)); } [Fact] @@ -391,7 +391,7 @@ public async Task BaseClassEntriesWithAnnotations() .For("Transport") .FindEntriesAsync(); Assert.Equal(2, transport.Count()); - transport.All(x => x.ContainsKey(FluentCommand.AnnotationsLiteral)).Should().BeTrue(); + Assert.True(transport.All(x => x.ContainsKey(FluentCommand.AnnotationsLiteral))); } [Fact] @@ -402,7 +402,7 @@ public async Task AllDerivedClassEntries() .For("Transport") .As("Ships") .FindEntriesAsync(); - transport.Single()["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", transport.Single()["ShipName"]); } [Fact] @@ -415,8 +415,8 @@ public async Task AllDerivedClassEntriesWithAnnotations() .FindEntriesAsync(); var ship = transport.Single(); - ship["ShipName"].Should().Be("Titanic"); - (ship[FluentCommand.AnnotationsLiteral] as ODataEntryAnnotations).TypeName.Should().Be("NorthwindModel.Ship"); + Assert.Equal("Titanic", ship["ShipName"]); + Assert.Equal("NorthwindModel.Ship", (ship[FluentCommand.AnnotationsLiteral] as ODataEntryAnnotations).TypeName); } [Fact] @@ -428,7 +428,7 @@ public async Task DerivedClassEntry() .As("Ships") .Filter("ShipName eq 'Titanic'") .FindEntryAsync(); - transport["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", transport["ShipName"]); } [Fact] @@ -439,7 +439,7 @@ public async Task BaseClassEntryByKey() .For("Transport") .Key(1) .FindEntryAsync(); - transport["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", transport["ShipName"]); } [Fact] @@ -451,7 +451,7 @@ public async Task DerivedClassEntryByKey() .As("Ships") .Key(1) .FindEntryAsync(); - transport["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", transport["ShipName"]); } [Fact] @@ -463,7 +463,7 @@ public async Task DerivedClassEntryBaseAndDerivedFields() .As("Ships") .Filter("TransportID eq 1 and ShipName eq 'Titanic'") .FindEntryAsync(); - transport["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", transport["ShipName"]); } [Fact] @@ -474,7 +474,7 @@ public async Task IsOfDerivedClassEntry() .For("Transport") .Filter("isof('NorthwindModel.Ship')") .FindEntryAsync(); - transport["ShipName"].Should().Be("Titanic"); + Assert.Equal("Titanic", transport["ShipName"]); } [Fact] @@ -485,7 +485,7 @@ public async Task IsOfAssociation() .For("Employees") .Filter("isof(Superior, 'NorthwindModel.Employee')") .FindEntryAsync(); - employee.Should().NotBeNull(); + Assert.NotNull(employee); } [Fact] @@ -496,7 +496,7 @@ public async Task CastToPrimitiveType() .For("Products") .Filter("ProductID eq cast(1L, 'Edm.Int32')") .FindEntryAsync(); - product.Should().NotBeNull(); + Assert.NotNull(product); } [Fact] @@ -507,7 +507,7 @@ public async Task CastInstanceToEntityType() .For("Employees") .Filter("cast('NorthwindModel.Employee') ne null") .FindEntryAsync(); - employee.Should().NotBeNull(); + Assert.NotNull(employee); } [Fact] @@ -518,7 +518,7 @@ public async Task CastPropertyToEntityType() .For("Employees") .Filter("cast(Superior, 'NorthwindModel.Employee') ne null") .FindEntryAsync(); - employee.Should().NotBeNull(); + Assert.NotNull(employee); } [Fact] diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/FindTypedTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/FindTypedTests.cs index 15318ffd..ae29c144 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/FindTypedTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/FindTypedTests.cs @@ -35,7 +35,7 @@ public async Task CombinedConditions() .For() .Filter(x => x.FirstName == "Nancy" && x.HireDate < DateTime.Now) .FindEntryAsync(); - employee.LastName.Should().Be("Davolio"); + Assert.Equal("Davolio", employee.LastName); } [Fact] @@ -47,7 +47,7 @@ public async Task CombinedConditionsWithMultipleFilters() .Filter(x => x.FirstName == "Nancy") .Filter(x => x.HireDate < DateTime.Now) .FindEntryAsync(); - employee.LastName.Should().Be("Davolio"); + Assert.Equal("Davolio", employee.LastName); } [Fact] @@ -63,7 +63,7 @@ public async Task CombineAll() .Expand(x => x.Category) .Select(x => x.Category) .FindEntriesAsync()).Single(); - product.Category.CategoryName.Should().Be("Seafood"); + Assert.Equal("Seafood", product.Category.CategoryName); } [Fact] @@ -79,7 +79,7 @@ public async Task CombineAllReverse() .OrderBy(x => x.ProductName) .ThenByDescending(x => x.UnitPrice) .FindEntriesAsync()).Single(); - product.Category.CategoryName.Should().Be("Seafood"); + Assert.Equal("Seafood", product.Category.CategoryName); } [Fact] @@ -96,7 +96,7 @@ await client .Filter(x => x.ProductName == "Test1") .Select(x => new { x.ProductID, x.ProductName, x.MappedEnglishName }) .FindEntryAsync(); - product.MappedEnglishName.Should().Be("EnglishTest"); + Assert.Equal("EnglishTest", product.MappedEnglishName); } [Fact] @@ -128,7 +128,7 @@ await client .For("Products") .Key(product.ProductID) .FindEntryAsync(); - product.ProductName.Should().Be("Test2"); + Assert.Equal("Test2", product.ProductName); } [Fact] @@ -145,7 +145,7 @@ await client .Filter(x => x.ProductName == "Test1") .Select(x => new { x.ProductID, x.ProductName, x.MappedEnglishName }) .FindEntryAsync(); - product.MappedEnglishName.Should().Be("EnglishTest"); + Assert.Equal("EnglishTest", product.MappedEnglishName); } [Fact] @@ -156,7 +156,7 @@ public async Task Subclass() .For("Products") .Filter(x => x.ProductName == "Chai") .FindEntryAsync(); - product.ProductName.Should().Be("Chai"); + Assert.Equal("Chai", product.ProductName); } [Fact] @@ -167,7 +167,7 @@ public async Task StringContains() .For() .Filter(x => x.ProductName.Contains("ai")) .FindEntriesAsync(); - products.Single().ProductName.Should().Be("Chai"); + Assert.Equal("Chai", products.Single().ProductName); } [Fact] @@ -179,7 +179,7 @@ public async Task StringContainsWithLocalVariable() .For() .Filter(x => x.ProductName.Contains(text)) .FindEntriesAsync(); - products.Single().ProductName.Should().Be("Chai"); + Assert.Equal("Chai", products.Single().ProductName); } [Fact] @@ -191,7 +191,7 @@ public async Task StringContainsWithArrayVariable() .For() .Filter(x => x.ProductName.Contains(text[0])) .FindEntriesAsync(); - products.Single().ProductName.Should().Be("Chai"); + Assert.Equal("Chai", products.Single().ProductName); } [Fact] @@ -202,7 +202,7 @@ public async Task StringNotContains() .For() .Filter(x => !x.ProductName.Contains("ai")) .FindEntriesAsync(); - products.First().ProductName.Should().NotBe("Chai"); + Assert.NotEqual("Chai", products.First().ProductName); } [Fact] @@ -213,7 +213,7 @@ public async Task StringStartsWith() .For() .Filter(x => x.ProductName.StartsWith("Ch")) .FindEntriesAsync(); - products.First().ProductName.Should().Be("Chai"); + Assert.Equal("Chai", products.First().ProductName); } [Fact] @@ -224,7 +224,7 @@ public async Task LengthOfStringEqual() .For() .Filter(x => x.ProductName.Length == 4) .FindEntriesAsync(); - products.First().ProductName.Should().Be("Chai"); + Assert.Equal("Chai", products.First().ProductName); } [Fact] @@ -235,7 +235,7 @@ public async Task SubstringWithPositionAndLengthEqual() .For() .Filter(x => x.ProductName.Substring(1, 2) == "ha") .FindEntriesAsync(); - products.First().ProductName.Should().Be("Chai"); + Assert.Equal("Chai", products.First().ProductName); } [Fact] @@ -247,7 +247,7 @@ public async Task SubstringWithPositionAndLengthEqualWithLocalVariable() .For() .Filter(x => x.ProductName.Substring(1, 2) == text) .FindEntriesAsync(); - products.First().ProductName.Should().Be("Chai"); + Assert.Equal("Chai", products.First().ProductName); } [Fact] @@ -304,7 +304,7 @@ public async Task SelectSingle() .Filter(x => x.ProductName == "Chai") .Select(x => x.ProductName) .FindEntryAsync(); - product.ProductName.Should().Be("Chai"); + Assert.Equal("Chai", product.ProductName); } [Fact] @@ -316,7 +316,7 @@ public async Task SelectMultiple() .Filter(x => x.ProductName == "Chai") .Select(x => new { x.ProductID, x.ProductName }) .FindEntryAsync(); - product.ProductName.Should().Be("Chai"); + Assert.Equal("Chai", product.ProductName); } [Fact(Skip = "NewExpression property names are not supported")] @@ -335,8 +335,8 @@ public async Task SelectMultipleRename() .Filter(x => x.ProductName == "Chai") .Select(x => new { x.ProductID, UnmappedName = x.ProductName }) .FindEntryAsync(); - product.UnmappedName.Should().Be("Chai"); - product.ProductName.Should().BeNull(); + Assert.Equal("Chai", product.UnmappedName); + Assert.Null(product.ProductName); } [Fact] @@ -348,7 +348,7 @@ public async Task ExpandOne() .OrderBy(x => x.ProductID) .Expand(x => x.Category) .FindEntriesAsync()).Last(); - product.Category.CategoryName.Should().Be("Condiments"); + Assert.Equal("Condiments", product.Category.CategoryName); } [Fact] @@ -432,7 +432,7 @@ public async Task ExpandMultipleLevelsWithCollection() .OrderBy(x => x.ProductID) .Expand(x => x.Category.Products.Select(y => y.Category)) .FindEntriesAsync()).Last(); - product.Category.Products.First().Category.CategoryName.Should().Be("Condiments"); + Assert.Equal("Condiments", product.Category.Products.First().Category.CategoryName); } [Fact] @@ -445,7 +445,7 @@ public async Task ExpandWithSelect() .Expand(x => x.Category) .Select(x => new { x.ProductName, x.Category.CategoryName }) .FindEntriesAsync()).Last(); - product.Category.CategoryName.Should().Be("Condiments"); + Assert.Equal("Condiments", product.Category.CategoryName); } [Fact] @@ -457,7 +457,7 @@ public async Task OrderBySingle() .Filter(x => x.ProductName == "Chai") .OrderBy(x => x.ProductName) .FindEntryAsync(); - product.ProductName.Should().Be("Chai"); + Assert.Equal("Chai", product.ProductName); } [Fact] @@ -469,7 +469,7 @@ public async Task OrderByMultiple() .Filter(x => x.ProductName == "Chai") .OrderBy(x => new { x.ProductID, x.ProductName }) .FindEntryAsync(); - product.ProductName.Should().Be("Chai"); + Assert.Equal("Chai", product.ProductName); } [Fact] @@ -481,7 +481,7 @@ public async Task OrderByExpanded() .Expand(x => x.Category) .OrderBy(x => new { x.Category.CategoryName }) .FindEntriesAsync()).Last(); - product.Category.CategoryName.Should().Be("Seafood"); + Assert.Equal("Seafood", product.Category.CategoryName); } [Fact] @@ -493,7 +493,7 @@ public async Task NavigateToSingle() .Key(new { ProductID = 2 }) .NavigateTo() .FindEntryAsync(); - category.CategoryName.Should().Be("Beverages"); + Assert.Equal("Beverages", category.CategoryName); } [Fact] @@ -505,7 +505,7 @@ public async Task NavigateToSingleByExpression() .Key(new { ProductID = 2 }) .NavigateTo(x => x.Category) .FindEntryAsync(); - category.CategoryName.Should().Be("Beverages"); + Assert.Equal("Beverages", category.CategoryName); } [Fact] @@ -532,7 +532,7 @@ public async Task NavigateToRecursive() .NavigateTo("Subordinates") .Key(3) .FindEntryAsync(); - employee.FirstName.Should().Be("Janet"); + Assert.Equal("Janet", employee.FirstName); } [Fact] @@ -547,7 +547,7 @@ public async Task NavigateToRecursiveByExpression() .NavigateTo(x => x.Subordinates) .Key(3) .FindEntryAsync(); - employee.FirstName.Should().Be("Janet"); + Assert.Equal("Janet", employee.FirstName); } [Fact] @@ -560,7 +560,7 @@ public async Task NavigateToRecursiveSingleClause() .NavigateTo(x => x.Superior.Superior.Subordinates) .Key(3) .FindEntryAsync(); - employee.FirstName.Should().Be("Janet"); + Assert.Equal("Janet", employee.FirstName); } [Fact] @@ -593,7 +593,7 @@ public async Task AllDerivedClassEntries() .For() .As() .FindEntriesAsync(); - transport.Single().ShipName.Should().Be("Titanic"); + Assert.Equal("Titanic", transport.Single().ShipName); } [Fact] @@ -604,7 +604,7 @@ public async Task AllDerivedClassEntriesWithAnnotations() .For() .As() .FindEntriesAsync(); - transport.Single().ShipName.Should().Be("Titanic"); + Assert.Equal("Titanic", transport.Single().ShipName); } [Fact] @@ -616,7 +616,7 @@ public async Task DerivedClassEntry() .As() .Filter(x => x.ShipName == "Titanic") .FindEntryAsync(); - transport.ShipName.Should().Be("Titanic"); + Assert.Equal("Titanic", transport.ShipName); } [Fact] @@ -639,7 +639,7 @@ public async Task DerivedClassEntryByKey() .As() .Key(1) .FindEntryAsync(); - transport.ShipName.Should().Be("Titanic"); + Assert.Equal("Titanic", transport.ShipName); } [Fact] @@ -651,7 +651,7 @@ public async Task DerivedClassEntryBaseAndDerivedFields() .As() .Filter(x => x.TransportID == 1 && x.ShipName == "Titanic") .FindEntryAsync(); - transport.ShipName.Should().Be("Titanic"); + Assert.Equal("Titanic", transport.ShipName); } [Fact] @@ -663,7 +663,7 @@ public async Task IsOfDerivedClassEntry() .Filter(x => x is Ship) .As() .FindEntryAsync(); - transport.ShipName.Should().Be("Titanic"); + Assert.Equal("Titanic", transport.ShipName); } [Fact] @@ -674,7 +674,7 @@ public async Task IsOfAssociation() .For() .Filter(x => x.Superior is Employee) .FindEntryAsync(); - employee.Should().NotBeNull(); + Assert.NotNull(employee); } [Fact] @@ -685,7 +685,7 @@ public async Task CastToPrimitiveType() .For() .Filter(x => x.CategoryID == (int)1L) .FindEntryAsync(); - product.Should().NotBeNull(); + Assert.NotNull(product); } [Fact] @@ -696,7 +696,7 @@ public async Task CastInstanceToEntityType() .For() .Filter(x => x != null) .FindEntryAsync(); - employee.Should().NotBeNull(); + Assert.NotNull(employee); } [Fact] @@ -707,7 +707,7 @@ public async Task CastPropertyToEntityType() .For() .Filter(x => x.Superior != null) .FindEntryAsync(); - employee.Should().NotBeNull(); + Assert.NotNull(employee); } [Fact] @@ -773,12 +773,12 @@ public async Task NameMatchResolverNotStrict() .For() .FindEntriesAsync(); Assert.NotEmpty(orderDetails1); - (orderDetails1.First().OrderID > 0).Should().BeTrue(); + Assert.True(orderDetails1.First().OrderID > 0); var orderDetails2 = await client .For() .FindEntriesAsync(); Assert.NotEmpty(orderDetails2); - (orderDetails2.First().Order_ID > 0).Should().BeTrue(); + Assert.True(orderDetails2.First().Order_ID > 0); } [Fact] @@ -791,6 +791,6 @@ public async Task NameMatchResolverCaseInsensitive() .For() .FindEntriesAsync(); Assert.NotEmpty(orderDetails); - (orderDetails.First().orderID > 0).Should().BeTrue(); + Assert.True(orderDetails.First().orderID > 0); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/FunctionTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/FunctionTests.cs index b3933c30..d9d699be 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/FunctionTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/FunctionTests.cs @@ -101,7 +101,7 @@ public async Task FunctionWithDateTime() .Set(new Entry() { { "dateTime", dateTime } }) .ExecuteAsScalarAsync(); - result.Should().Be(dateTime); + Assert.Equal(dateTime, result); } [Fact] @@ -115,7 +115,7 @@ public async Task FunctionWithLocalDateTime() .Set(new Entry() { { "dateTime", dateTime } }) .ExecuteAsScalarAsync(); - result.Should().Be(dateTime); + Assert.Equal(dateTime, result); } [Fact] @@ -144,8 +144,8 @@ public async Task FunctionWithComplexType() .ExecuteAsSingleAsync(); result = result["PassThroughAddress"] as IDictionary; - result["City"].Should().Be("Oslo"); - result["Country"].Should().Be("Norway"); + Assert.Equal("Oslo", result["City"]); + Assert.Equal("Norway", result["Country"]); } [Fact] @@ -158,8 +158,8 @@ public async Task FunctionWithComplexTypeCollectionSingleElement() .Set(new Entry() { { "count", 1 } }) .ExecuteAsSingleAsync()); - result["City"].Should().Be("Oslo"); - result["Country"].Should().Be("Norway"); + Assert.Equal("Oslo", result["City"]); + Assert.Equal("Norway", result["Country"]); } [Fact] @@ -172,10 +172,10 @@ public async Task FunctionWithComplexTypeCollectionMultipleElements() .Set(new Entry() { { "count", 3 } }) .ExecuteAsEnumerableAsync()).ToArray(); - result[0]["City"].Should().Be("Oslo"); - result[0]["Country"].Should().Be("Norway"); - result[1]["City"].Should().Be("Oslo"); - result[2]["City"].Should().Be("Oslo"); + Assert.Equal("Oslo", result[0]["City"]); + Assert.Equal("Norway", result[0]["Country"]); + Assert.Equal("Oslo", result[1]["City"]); + Assert.Equal("Oslo", result[2]["City"]); } [Fact] @@ -188,6 +188,6 @@ public async Task FunctionWithComplexTypeCollectionEmpty() .Set(new Entry() { { "count", 0 } }) .ExecuteAsEnumerableAsync()).ToArray(); - result.Should().BeEmpty(); + Assert.Empty(result); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/InsertDynamicTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/InsertDynamicTests.cs index abf56438..1fee6988 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/InsertDynamicTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/InsertDynamicTests.cs @@ -71,7 +71,7 @@ public async Task InsertProductWithCategoryByID() .Expand(x.Products) .Filter(x.CategoryName == "Test3") .FindEntryAsync(); - ((category.Products as IEnumerable).Count() == 1).Should().BeTrue(); + Assert.True((category.Products as IEnumerable).Count() == 1); } [Fact] @@ -95,7 +95,7 @@ public async Task InsertProductWithCategoryByAssociation() .Expand(x.Products) .Filter(x.CategoryName == "Test5") .FindEntryAsync(); - ((category.Products as IEnumerable).Count() == 1).Should().BeTrue(); + Assert.True((category.Products as IEnumerable).Count() == 1); } [Fact] diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/InsertTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/InsertTests.cs index 09a55810..3fe14e31 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/InsertTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/InsertTests.cs @@ -40,8 +40,8 @@ public async Task InsertAutogeneratedID() .Set(new { ProductName = "Test1", UnitPrice = 18m }) .InsertEntryAsync(); - ((int)product["ProductID"] > 0).Should().BeTrue(); - product["ProductName"].Should().Be("Test1"); + Assert.True((int)product["ProductID"] > 0); + Assert.Equal("Test1", product["ProductName"]); } [Fact] @@ -57,7 +57,7 @@ public async Task InsertExpando() .Set(expando) .InsertEntryAsync()); - ((int)product["ProductID"] > 0).Should().BeTrue(); + Assert.True((int)product["ProductID"] > 0); } [Fact] @@ -73,14 +73,14 @@ public async Task InsertProductWithCategoryByID() .Set(new { ProductName = "Test4", UnitPrice = 18m, CategoryID = category["CategoryID"] }) .InsertEntryAsync(); - product["ProductName"].Should().Be("Test4"); - product["CategoryID"].Should().Be(category["CategoryID"]); + Assert.Equal("Test4", product["ProductName"]); + Assert.Equal(category["CategoryID"], product["CategoryID"]); category = await client .For("Categories") .Expand("Products") .Filter("CategoryName eq 'Test3'") .FindEntryAsync(); - ((category["Products"] as IEnumerable).Count() == 1).Should().BeTrue(); + Assert.True((category["Products"] as IEnumerable).Count() == 1); } [Fact(Skip = "Cannot be mocked")] @@ -97,14 +97,14 @@ public async Task InsertProductRenewHttpConnection() .Set(new { ProductName = "Test4", UnitPrice = 18m, CategoryID = category["CategoryID"] }) .InsertEntryAsync(); - product["ProductName"].Should().Be("Test4"); - product["CategoryID"].Should().Be(category["CategoryID"]); + Assert.Equal("Test4", product["ProductName"]); + Assert.Equal(category["CategoryID"], product["CategoryID"]); category = await client .For("Categories") .Expand("Products") .Filter("CategoryName eq 'Test3'") .FindEntryAsync(); - ((category["Products"] as IEnumerable).Count() == 1).Should().BeTrue(); + Assert.True((category["Products"] as IEnumerable).Count() == 1); } [Fact] @@ -120,14 +120,14 @@ public async Task InsertProductWithCategoryByAssociation() .Set(new { ProductName = "Test6", UnitPrice = 18m, Category = category }) .InsertEntryAsync(); - product["ProductName"].Should().Be("Test6"); - product["CategoryID"].Should().Be(category["CategoryID"]); + Assert.Equal("Test6", product["ProductName"]); + Assert.Equal(category["CategoryID"], product["CategoryID"]); category = await client .For("Categories") .Expand("Products") .Filter("CategoryName eq 'Test5'") .FindEntryAsync(); - ((category["Products"] as IEnumerable).Count() == 1).Should().BeTrue(); + Assert.True((category["Products"] as IEnumerable).Count() == 1); } [Fact] @@ -140,6 +140,6 @@ public async Task InsertShip() .Set(new { ShipName = "Test1" }) .InsertEntryAsync(); - ship["ShipName"].Should().Be("Test1"); + Assert.Equal("Test1", ship["ShipName"]); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/InsertTypedTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/InsertTypedTests.cs index 2b29d105..6a95985b 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/InsertTypedTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/InsertTypedTests.cs @@ -27,7 +27,7 @@ public async Task InsertAutogeneratedID() .InsertEntryAsync(); (product.ProductID > 0).Should().BeTrue(); - product.ProductName.Should().Be("Test1"); + Assert.Equal("Test1", product.ProductName); } [Fact] @@ -44,7 +44,7 @@ public async Task InsertWithSelect() .InsertEntryAsync(); Assert.NotEqual(default, product.ProductID); - product.ProductName.Should().Be(default); + Assert.Equal(default, product.ProductName); Assert.Equal(default, product.UnitPrice); } @@ -57,8 +57,8 @@ public async Task InsertWithMappedColumn() .Set(new Product { ProductName = "Test1", UnitPrice = 18m, MappedEnglishName = "EnglishTest" }) .InsertEntryAsync(); - product.ProductName.Should().Be("Test1"); - product.MappedEnglishName.Should().Be("EnglishTest"); + Assert.Equal("Test1", product.ProductName); + Assert.Equal("EnglishTest", product.MappedEnglishName); } [Fact] @@ -74,14 +74,14 @@ public async Task InsertProductWithCategoryByID() .Set(new { ProductName = "Test4", UnitPrice = 18m, CategoryID = category.CategoryID }) .InsertEntryAsync(); - product.ProductName.Should().Be("Test4"); + Assert.Equal("Test4", product.ProductName); Assert.Equal(category.CategoryID, product.CategoryID); category = await client .For() .Expand(x => new { x.Products }) .Filter(x => x.CategoryName == "Test3") .FindEntryAsync(); - (category.Products.Length == 1).Should().BeTrue(); + Assert.True(category.Products.Length == 1); } [Fact] @@ -97,14 +97,14 @@ public async Task InsertProductWithCategoryByAssociation() .Set(new { ProductName = "Test6", UnitPrice = 18m, Category = category }) .InsertEntryAsync(); - product.ProductName.Should().Be("Test6"); + Assert.Equal("Test6", product.ProductName); Assert.Equal(category.CategoryID, product.CategoryID); category = await client .For() .Expand(x => new { x.Products }) .Filter(x => x.CategoryName == "Test5") .FindEntryAsync(); - (category.Products.Length == 1).Should().BeTrue(); + Assert.True(category.Products.Length == 1); } [Fact] @@ -121,7 +121,7 @@ public async Task InsertCategoryWithPictureAsBytes() .Expand(x => new { x.Products }) .Filter(x => x.CategoryName == "Test7") .FindEntryAsync(); - (category.Picture.Length > 0).Should().BeTrue(); + Assert.True(category.Picture.Length > 0); } [Fact] @@ -138,7 +138,7 @@ public async Task InsertCategoryWithPictureAsString() .Expand(x => new { x.Products }) .Filter(x => x.CategoryName == "Test7") .FindEntryAsync(); - (category.Picture.Length > 0).Should().BeTrue(); + Assert.True(category.Picture.Length > 0); } [Fact] @@ -151,6 +151,6 @@ public async Task InsertShip() .Set(new Ship { ShipName = "Test1" }) .InsertEntryAsync(); - ship.ShipName.Should().Be("Test1"); + Assert.Equal("Test1", ship.ShipName); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/LinkTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/LinkTests.cs index 0adf571e..c6fa490e 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/LinkTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/LinkTests.cs @@ -61,6 +61,6 @@ await client .For("Products") .Filter("ProductName eq 'Test5'") .FindEntryAsync(); - product["CategoryID"].Should().BeNull(); + Assert.Null(product["CategoryID"]); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/UpdateTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/UpdateTests.cs index d107aa3c..76f1ef8d 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/UpdateTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/UpdateTests.cs @@ -72,7 +72,7 @@ await client .Filter("ProductName eq 'Test1'") .FindEntryAsync(); - product["UnitPrice"].Should().Be(123m); + Assert.Equal(123m, product["UnitPrice"]); } [Fact] @@ -90,7 +90,7 @@ public async Task UpdateMultipleWithResult() .Set(new { UnitPrice = 123m }) .UpdateEntriesAsync()).Single(); - product["UnitPrice"].Should().Be(123m); + Assert.Equal(123m, product["UnitPrice"]); } [Fact] @@ -107,14 +107,14 @@ public async Task UpdateMultipleNoResult() .Filter("ProductName eq 'Test1'") .Set(new { UnitPrice = 123m }) .UpdateEntriesAsync(false)).Single(); - product.Should().BeNull(); + Assert.Null(product); product = await client .For("Products") .Filter("ProductName eq 'Test1'") .FindEntryAsync(); - product["UnitPrice"].Should().Be(123m); + Assert.Equal(123m, product["UnitPrice"]); } [Fact] @@ -137,7 +137,7 @@ await client .Filter("ProductName eq 'Test1'") .FindEntryAsync(); - product["UnitPrice"].Should().Be(456m); + Assert.Equal(456m, product["UnitPrice"]); } [Fact] @@ -163,7 +163,7 @@ await client .Key(employee["EmployeeID"]) .FindEntryAsync(); - employee["HireDate"].Should().Be(tomorrow); + Assert.Equal(tomorrow, employee["HireDate"]); } [Fact] @@ -189,7 +189,7 @@ await client .For("Products") .Filter("ProductID eq " + product["ProductID"]) .FindEntryAsync(); - product["CategoryID"].Should().Be(category["CategoryID"]); + Assert.Equal(category["CategoryID"], product["CategoryID"]); category = await client .For("Categories") .Filter("CategoryID eq " + category["CategoryID"]) @@ -221,7 +221,7 @@ await client .For("Products") .Filter("ProductID eq " + product["ProductID"]) .FindEntryAsync(); - product["CategoryID"].Should().Be(category["CategoryID"]); + Assert.Equal(category["CategoryID"], product["CategoryID"]); category = await client .For("Categories") .Filter("CategoryID eq " + category["CategoryID"]) @@ -253,7 +253,7 @@ await client .For("Products") .Filter("ProductID eq " + product["ProductID"]) .FindEntryAsync(); - product["CategoryID"].Should().BeNull(); + Assert.Null(product["CategoryID"]); } [Fact] @@ -304,6 +304,6 @@ public async Task UpdateDerived() .Set(new { ShipName = "Test2" }) .UpdateEntryAsync(); - ship["ShipName"].Should().Be("Test2"); + Assert.Equal("Test2", ship["ShipName"]); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/UpdateTypedTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/UpdateTypedTests.cs index 0333e107..4a88b262 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/UpdateTypedTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/UpdateTypedTests.cs @@ -253,7 +253,7 @@ await client .For() .Filter(x => x.ProductID == product.ProductID) .FindEntryAsync(); - product.CategoryID.Should().BeNull(); + Assert.Null(product.CategoryID); } [Fact] @@ -317,8 +317,8 @@ await client .For("Products") .Key(product.ProductID) .FindEntryAsync(); - product.ProductName.Should().Be("Test7"); - product.CategoryID.Should().NotBeNull(); + Assert.Equal("Test7", product.ProductName); + Assert.NotNull(product.CategoryID); } [Fact] @@ -338,6 +338,6 @@ public async Task UpdateDerived() .Set(new { ShipName = "Test2" }) .UpdateEntryAsync(); - ship.ShipName.Should().Be("Test2"); + Assert.Equal("Test2", ship.ShipName); } } diff --git a/src/Simple.OData.Client.UnitTests/FluentApi/WithHeaderTests.cs b/src/Simple.OData.Client.UnitTests/FluentApi/WithHeaderTests.cs index ce9fb3fd..a3975d37 100644 --- a/src/Simple.OData.Client.UnitTests/FluentApi/WithHeaderTests.cs +++ b/src/Simple.OData.Client.UnitTests/FluentApi/WithHeaderTests.cs @@ -35,8 +35,8 @@ public async Task WithHeaders() .BuildRequestFor() .FindEntryAsync(); - request.GetRequest().RequestMessage.Headers.GetValues("header1").SingleOrDefault().Should().Be("header1Value"); - request.GetRequest().RequestMessage.Headers.GetValues("header2").SingleOrDefault().Should().Be("header2Value"); + Assert.Equal("header1Value", request.GetRequest().RequestMessage.Headers.GetValues("header1").SingleOrDefault()); + Assert.Equal("header2Value", request.GetRequest().RequestMessage.Headers.GetValues("header2").SingleOrDefault()); } private (ODataClient client, IDictionary> headers) CreateClient() @@ -47,12 +47,12 @@ public async Task WithHeaders() private static void AssertHeader(IDictionary> headers, string name, string value) { - (headers.TryGetValue(name, out var values) && values.Single() == value).Should().BeTrue(); + Assert.True(headers.TryGetValue(name, out var values) && values.Single() == value); } private static void AssertHeader(ODataRequest request, string name, string value) { - (request.RequestMessage.Headers.TryGetValues(name, out var values) && values.Single() == value).Should().BeTrue(); + Assert.True(request.RequestMessage.Headers.TryGetValues(name, out var values) && values.Single() == value); } [Fact] diff --git a/src/Simple.OData.Client.UnitTests/Reflection/MemberAccessorTests.cs b/src/Simple.OData.Client.UnitTests/Reflection/MemberAccessorTests.cs index cb496e07..930006cf 100644 --- a/src/Simple.OData.Client.UnitTests/Reflection/MemberAccessorTests.cs +++ b/src/Simple.OData.Client.UnitTests/Reflection/MemberAccessorTests.cs @@ -41,13 +41,13 @@ public void ShouldGetInstanceFieldValue() [Fact] public void ShouldGetStaticPropertyValue() { - MemberAccessor.GetValue(null, typeof(TestClass).GetProperty(nameof(TestClass.StaticProperty))).Should().Be(TestClass.StaticProperty); + Assert.Equal(TestClass.StaticProperty, MemberAccessor.GetValue(null, typeof(TestClass).GetProperty(nameof(TestClass.StaticProperty)))); } [Fact] public void ShouldGetStaticFieldValue() { - MemberAccessor.GetValue(null, typeof(TestClass).GetField(nameof(TestClass.staticField))).Should().Be(TestClass.staticField); + Assert.Equal(TestClass.staticField, MemberAccessor.GetValue(null, typeof(TestClass).GetField(nameof(TestClass.staticField)))); } @@ -65,7 +65,7 @@ public void ShouldSetInstancePropertyValue() MemberAccessor.SetValue(instance, nameof(TestClass.InstanceProprety), "test"); - instance.InstanceProprety.Should().Be("test"); + Assert.Equal("test", instance.InstanceProprety); } [Fact] @@ -78,7 +78,7 @@ public void ShouldSetInstanceFieldValue() MemberAccessor.SetValue(instance, nameof(TestClass.instanceField), "test"); - instance.instanceField.Should().Be("test"); + Assert.Equal("test", instance.instanceField); } [Fact] @@ -86,7 +86,7 @@ public void ShouldSetStaticPropertyValue() { MemberAccessor.SetValue(null, typeof(TestClass).GetProperty(nameof(TestClass.StaticPropertyToSet)), "test"); - TestClass.StaticPropertyToSet.Should().Be("test"); + Assert.Equal("test", TestClass.StaticPropertyToSet); } [Fact] @@ -94,7 +94,7 @@ public void ShouldSetStaticFieldValue() { MemberAccessor.SetValue(null, typeof(TestClass).GetField(nameof(TestClass.staticFieldToSet)), "test"); - TestClass.staticFieldToSet.Should().Be("test"); + Assert.Equal("test", TestClass.staticFieldToSet); } }