Skip to content

Commit

Permalink
#405 removed FluentAssertions from usings (#416)
Browse files Browse the repository at this point in the history
* #405 removed FluentAssertions from usings

* #405 removed FluentAssertion from Directory.Build.props and Directory.Packages.props

* #405 added Assert.NotEmpty and ToList (multiple iterations)
  • Loading branch information
anoordover authored Jan 29, 2025
1 parent 5da31f0 commit f3946ee
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 45 deletions.
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<!-- Testing packages -->
<PackageVersion Include="Aspire.Hosting.Testing" Version="$(AspireVersion)" />
<PackageVersion Include="coverlet.collector" Version="6.0.3" />
<PackageVersion Include="FluentAssertions" Version="7.0.0" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.5.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;

namespace CommunityToolkit.Aspire.Hosting.Bun.Tests;

Expand All @@ -15,7 +14,7 @@ public async Task ResourceStartsAndRespondsOk()

var response = await httpClient.GetAsync("/");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var body = await response.Content.ReadAsStringAsync();

Assert.Equal("Hello, Bun!", body);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;

namespace CommunityToolkit.Aspire.Hosting.Deno.Tests;

Expand All @@ -16,7 +15,7 @@ public async Task ResourceStartsAndRespondsOk()

var response = await httpClient.GetAsync("/");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
Expand All @@ -29,6 +28,6 @@ public async Task ApiResourceStartsAndRespondsOk()

var response = await httpClient.GetAsync("/weather");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Aspire.Hosting;
using Microsoft.AspNetCore.Http;
using System.Diagnostics;

namespace CommunityToolkit.Aspire.Hosting.Deno.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Components.Common.Tests;
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;
using Projects;
using System.Net.Http.Json;

Expand All @@ -24,7 +23,7 @@ await fixture.ResourceNotificationService

var response = await httpClient.GetAsync("/");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
Expand All @@ -41,12 +40,12 @@ await fixture.ResourceNotificationService
var httpClient = fixture.CreateHttpClient(resourceName);

var createResponse = await httpClient.PostAsJsonAsync("/account/create", new { });
createResponse.StatusCode.Should().Be(HttpStatusCode.Created);
Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode);

var location = createResponse.Headers.Location;

var getResponse = await httpClient.GetAsync(location);
getResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);

var account = await getResponse.Content.ReadFromJsonAsync<AccountDto>();
Assert.NotNull(account);
Expand All @@ -65,15 +64,15 @@ await fixture.ResourceNotificationService
var httpClient = fixture.CreateHttpClient(resourceName);

var createResponse = await httpClient.PostAsJsonAsync("/account/create", new { });
createResponse.StatusCode.Should().Be(HttpStatusCode.Created);
Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode);

var location = createResponse.Headers.Location;

var depositResponse = await httpClient.PostAsJsonAsync($"{location!}/deposit", new { Amount = 50 });
depositResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, depositResponse.StatusCode);

var getResponse = await httpClient.GetAsync(location);
getResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);

var account = await getResponse.Content.ReadFromJsonAsync<AccountDto>();
Assert.NotNull(account);
Expand All @@ -92,15 +91,15 @@ await fixture.ResourceNotificationService
var httpClient = fixture.CreateHttpClient(resourceName);

var createResponse = await httpClient.PostAsJsonAsync("/account/create", new { });
createResponse.StatusCode.Should().Be(HttpStatusCode.Created);
Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode);

var location = createResponse.Headers.Location;

var depositResponse = await httpClient.PostAsJsonAsync($"{location!}/withdraw", new { Amount = 90 });
depositResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, depositResponse.StatusCode);

var getResponse = await httpClient.GetAsync(location);
getResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);

var account = await getResponse.Content.ReadFromJsonAsync<AccountDto>();
Assert.NotNull(account);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;

namespace CommunityToolkit.Aspire.Hosting.Golang.Tests;

Expand All @@ -16,6 +15,6 @@ public async Task ResourceStartsAndRespondsOk()

var response = await httpClient.GetAsync("/ping");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;
using Aspire.Components.Common.Tests;

namespace CommunityToolkit.Aspire.Hosting.Java.Tests;
Expand All @@ -19,6 +18,6 @@ public async Task AppResourceWillRespondWithOk(string resourceName)

var response = await httpClient.GetAsync("/");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CommunityToolkit.Aspire.Testing;
using Aspire.Components.Common.Tests;
using FluentAssertions;
using System.Net.Http.Json;

namespace CommunityToolkit.Aspire.Hosting.Meilisearch.Tests;
Expand All @@ -17,7 +16,7 @@ public async Task ResourceStartsAndRespondsOk()

var response = await httpClient.GetAsync("/");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
Expand All @@ -30,10 +29,10 @@ public async Task ApiServiceCreateData()
var httpClient = fixture.CreateHttpClient(resourceName);

var createResponse = await httpClient.GetAsync("/create").WaitAsync(TimeSpan.FromMinutes(5));
createResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, createResponse.StatusCode);

var getResponse = await httpClient.GetAsync("/get");
getResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);

var data = await getResponse.Content.ReadFromJsonAsync<List<object>>();
Assert.NotNull(data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;

namespace CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.Tests;

Expand All @@ -18,6 +17,6 @@ public async Task ResourceStartsAndRespondsOk(string appName)

var response = await httpClient.GetAsync("/");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CommunityToolkit.Aspire.Testing;
using Aspire.Components.Common.Tests;
using FluentAssertions;
using OllamaSharp;

namespace CommunityToolkit.Aspire.Hosting.Ollama.Tests;
Expand All @@ -17,14 +16,14 @@ public async Task ResourceStartsAndRespondsOk()

var response = await httpClient.GetAsync("/");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
public async Task OllamaListsAvailableModels()
{
var distributedAppModel = fixture.App.Services.GetRequiredService<DistributedApplicationModel>();
var modelResources = distributedAppModel.Resources.OfType<OllamaModelResource>();
var modelResources = distributedAppModel.Resources.OfType<OllamaModelResource>().ToList();
var rns = fixture.ResourceNotificationService;

await Task.WhenAll([
Expand All @@ -33,9 +32,9 @@ .. modelResources.Select(m => rns.WaitForResourceHealthyAsync(m.Name))
]).WaitAsync(TimeSpan.FromMinutes(5));
var httpClient = fixture.CreateHttpClient("ollama");

var models = await new OllamaApiClient(httpClient).ListLocalModelsAsync();

models.Should().NotBeEmpty();
models.Should().HaveCount(modelResources.Count());
var models = (await new OllamaApiClient(httpClient).ListLocalModelsAsync()).ToList();
Assert.NotEmpty(models);
Assert.Equal(modelResources.Count, models.Count);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;

namespace CommunityToolkit.Aspire.Hosting.Python.Extensions.Tests;

Expand All @@ -17,6 +16,6 @@ public async Task ResourceStartsAndRespondsOk(string appName)

var response = await httpClient.GetAsync("/");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;

namespace CommunityToolkit.Aspire.Hosting.Rust.Tests;

Expand All @@ -16,6 +15,6 @@ public async Task ResourceStartsAndRespondsOk()
var httpClient = fixture.CreateHttpClient(appName);
var response = await httpClient.GetAsync("/ping");

response.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Aspire.Testing;
using FluentAssertions;
using System.Data.Common;
using System.Net.Http.Json;

Expand Down Expand Up @@ -34,10 +33,10 @@ public async Task ApiServiceCreateTestItemWithSqliteClient()
var httpClient = fixture.CreateHttpClient(resourceName);

var createResponse = await httpClient.PostAsJsonAsync("/test", "test");
createResponse.StatusCode.Should().Be(HttpStatusCode.Created);
Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode);

var getResponse = await httpClient.GetAsync("/test");
getResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);

var data = await getResponse.Content.ReadAsStringAsync();
Assert.NotNull(data);
Expand All @@ -53,10 +52,10 @@ public async Task ApiServiceCreateBlogItem()
var httpClient = fixture.CreateHttpClient(resourceName);

var createResponse = await httpClient.PostAsJsonAsync("/blog", new { Url = "https://example.com" });
createResponse.StatusCode.Should().Be(HttpStatusCode.Created);
Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode);

var getResponse = await httpClient.GetAsync("/blog");
getResponse.StatusCode.Should().Be(HttpStatusCode.OK);
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);

var data = await getResponse.Content.ReadFromJsonAsync<List<Blog>>();
Assert.NotNull(data);
Expand Down
1 change: 0 additions & 1 deletion tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ItemGroup>
<PackageReference Include="Aspire.Hosting.Testing" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="MartinCostello.Logging.XUnit" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
Expand Down

0 comments on commit f3946ee

Please sign in to comment.