From 5cc6ec3405dd546851cfd6c7a88c35a57453c565 Mon Sep 17 00:00:00 2001 From: zijianhuang Date: Sun, 16 Jun 2024 18:03:28 +1000 Subject: [PATCH] some legacy stuffs removed --- FonlowTesting.sln | 7 - .../DotNetHostCollection.cs | 15 - .../IntegrationTestsCore.csproj | 44 --- Tests/IntegrationTestsCore/README.md | 3 - Tests/IntegrationTestsCore/UnitTest1.cs | 39 -- Tests/IntegrationTestsCore/appsettings.json | 6 - Tests/IntegrationTestsCore/xunit.runner.json | 4 - Tests/WebApiTestsCore/README.md | 8 - Tests/WebApiTestsCore/ValuesApiIntegration.cs | 348 ------------------ Tests/WebApiTestsCore/WebApiTestsCore.csproj | 38 -- Tests/WebApiTestsCore/appsettings.json | 10 - 11 files changed, 522 deletions(-) delete mode 100644 Tests/IntegrationTestsCore/DotNetHostCollection.cs delete mode 100644 Tests/IntegrationTestsCore/IntegrationTestsCore.csproj delete mode 100644 Tests/IntegrationTestsCore/README.md delete mode 100644 Tests/IntegrationTestsCore/UnitTest1.cs delete mode 100644 Tests/IntegrationTestsCore/appsettings.json delete mode 100644 Tests/IntegrationTestsCore/xunit.runner.json delete mode 100644 Tests/WebApiTestsCore/README.md delete mode 100644 Tests/WebApiTestsCore/ValuesApiIntegration.cs delete mode 100644 Tests/WebApiTestsCore/WebApiTestsCore.csproj delete mode 100644 Tests/WebApiTestsCore/appsettings.json diff --git a/FonlowTesting.sln b/FonlowTesting.sln index 8565577..d0b5765 100644 --- a/FonlowTesting.sln +++ b/FonlowTesting.sln @@ -23,8 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DemoCoreWeb.ClientApi", "De EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DemoServices", "DemoServices", "{5990F58B-3B71-44C4-AA3B-A4167A2E7C4E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTestsCore", "Tests\IntegrationTestsCore\IntegrationTestsCore.csproj", "{1616EB5B-A461-4CD1-B88D-91803A0090C6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceCommandIntegrationTests", "Tests\ServiceCommandTests\ServiceCommandIntegrationTests.csproj", "{7B224B32-9D36-4BF4-8363-1864F1700C13}" EndProject Global @@ -49,10 +47,6 @@ Global {4526EFF6-B31B-412F-BDA8-007565359EB6}.Debug|Any CPU.Build.0 = Debug|Any CPU {4526EFF6-B31B-412F-BDA8-007565359EB6}.Release|Any CPU.ActiveCfg = Release|Any CPU {4526EFF6-B31B-412F-BDA8-007565359EB6}.Release|Any CPU.Build.0 = Release|Any CPU - {1616EB5B-A461-4CD1-B88D-91803A0090C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1616EB5B-A461-4CD1-B88D-91803A0090C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1616EB5B-A461-4CD1-B88D-91803A0090C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1616EB5B-A461-4CD1-B88D-91803A0090C6}.Release|Any CPU.Build.0 = Release|Any CPU {7B224B32-9D36-4BF4-8363-1864F1700C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7B224B32-9D36-4BF4-8363-1864F1700C13}.Debug|Any CPU.Build.0 = Debug|Any CPU {7B224B32-9D36-4BF4-8363-1864F1700C13}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -64,7 +58,6 @@ Global GlobalSection(NestedProjects) = preSolution {0F565F06-496A-4368-A28D-B18DDBFEF21A} = {5990F58B-3B71-44C4-AA3B-A4167A2E7C4E} {4526EFF6-B31B-412F-BDA8-007565359EB6} = {5990F58B-3B71-44C4-AA3B-A4167A2E7C4E} - {1616EB5B-A461-4CD1-B88D-91803A0090C6} = {A3630AD3-6DC6-4426-924A-838EEB803714} {7B224B32-9D36-4BF4-8363-1864F1700C13} = {A3630AD3-6DC6-4426-924A-838EEB803714} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/Tests/IntegrationTestsCore/DotNetHostCollection.cs b/Tests/IntegrationTestsCore/DotNetHostCollection.cs deleted file mode 100644 index e76d579..0000000 --- a/Tests/IntegrationTestsCore/DotNetHostCollection.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -namespace IntegrationTests -{ - /// - /// - /// - [CollectionDefinition("ServiceLaunch")] - public class DotNetHostCollection : ICollectionFixture - { - // This class has no code, and is never created. Its purpose is simply - // to be the place to apply [CollectionDefinition] and all the - // ICollectionFixture<> interfaces. - } -} diff --git a/Tests/IntegrationTestsCore/IntegrationTestsCore.csproj b/Tests/IntegrationTestsCore/IntegrationTestsCore.csproj deleted file mode 100644 index bac9e40..0000000 --- a/Tests/IntegrationTestsCore/IntegrationTestsCore.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - - net8.0 - - false - - - - - - - - - PreserveNewest - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - PreserveNewest - - - - diff --git a/Tests/IntegrationTestsCore/README.md b/Tests/IntegrationTestsCore/README.md deleted file mode 100644 index 2bea6dd..0000000 --- a/Tests/IntegrationTestsCore/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Test FFonlow.Testing.DotNetHostFixture. - -Demostrate how to launch DotNet Kestrel Web server hosting ASP.NET Core Web service "DemoCoreWeb" for the integration test suite. \ No newline at end of file diff --git a/Tests/IntegrationTestsCore/UnitTest1.cs b/Tests/IntegrationTestsCore/UnitTest1.cs deleted file mode 100644 index 6830eb6..0000000 --- a/Tests/IntegrationTestsCore/UnitTest1.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Xunit; -using Fonlow.Testing; - -namespace IntegrationTestsCore -{ - public class WhetherApiFixture : DefaultHttpClient - { - public WhetherApiFixture() - { - Api = new DemoCoreWeb.Controllers.Client.WeatherForecast(this.HttpClient); - } - - public DemoCoreWeb.Controllers.Client.WeatherForecast Api { get; private set; } - } - - [Collection("ServiceLaunch")] - public class UnitTest1: IClassFixture - { - public UnitTest1(WhetherApiFixture fixture) - { - api = fixture.Api; - } - - DemoCoreWeb.Controllers.Client.WeatherForecast api; - - [Fact] - public void Test1() - { - Assert.NotEmpty(api.Get()); - } - - [Fact] - public void TestGetAppSettings() - { - var r = api.GetSettings(); - Assert.Equal("OK", r); - } - } -} diff --git a/Tests/IntegrationTestsCore/appsettings.json b/Tests/IntegrationTestsCore/appsettings.json deleted file mode 100644 index 2ac15f8..0000000 --- a/Tests/IntegrationTestsCore/appsettings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Testing": { - "baseUrl": "http://127.0.0.1:5000/", - "DotNetServiceAssemblyPath": "../../../../../DemoCoreWeb/bin/Release/net8.0/DemoCoreWeb.dll" - } -} \ No newline at end of file diff --git a/Tests/IntegrationTestsCore/xunit.runner.json b/Tests/IntegrationTestsCore/xunit.runner.json deleted file mode 100644 index f5d77ac..0000000 --- a/Tests/IntegrationTestsCore/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", - "diagnosticMessages": true -} \ No newline at end of file diff --git a/Tests/WebApiTestsCore/README.md b/Tests/WebApiTestsCore/README.md deleted file mode 100644 index ae20ffd..0000000 --- a/Tests/WebApiTestsCore/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Test Fonlow.Testing.IisExpressFixture. - -Demostrate how to launch IIS Express hosting ASP.NET Web service "DemoWebApi" on .NET Framework 4.8 for the integration test suite. - - -**Remarks:** - -* This csproj retires since 2024-05-17, and is removed from sln. \ No newline at end of file diff --git a/Tests/WebApiTestsCore/ValuesApiIntegration.cs b/Tests/WebApiTestsCore/ValuesApiIntegration.cs deleted file mode 100644 index 8922a86..0000000 --- a/Tests/WebApiTestsCore/ValuesApiIntegration.cs +++ /dev/null @@ -1,348 +0,0 @@ -using System; -using Xunit; -using System.Threading.Tasks; -using System.Net.Http; -using Newtonsoft.Json; -using System.Linq; - -namespace WebApiTestsCore -{ - [CollectionDefinition("WebApiInit")] - public class IisCollection : ICollectionFixture - { - // This class has no code, and is never created. Its purpose is simply - // to be the place to apply [CollectionDefinition] and all the - // ICollectionFixture<> interfaces. - } - - [Collection("WebApiInit")] - public class ValuesApiIntegration : IClassFixture - { - public ValuesApiIntegration(ValuesFixture fixture) - { - api = fixture.Api; - } - - Values api; - - [Fact] - public void TestValuesGet() - { - //var task = authorizedClient.GetStringAsync(new Uri(baseUri, "api/Values")); - //var text = task.Result; - //var array = JArray.Parse(text); - var array = api.Get().ToArray(); - Assert.Equal("value2", array[1]); - } - - - - [Fact] - public void TestValuesDelete() - { - api.Delete(1); - } - } - - ///// - ///// Test with Proxy http://localhost:8888 - ///// - //public class ValuesApiWithProxyIntegration : IClassFixture - //{ - // public ValuesApiWithProxyIntegration(ValuesWithProxyFixture fixture) - // { - // api = fixture.Api; - // } - - // Values api; - - // [Fact] - // public void TestValuesGet() - // { - // //var task = authorizedClient.GetStringAsync(new Uri(baseUri, "api/Values")); - // //var text = task.Result; - // //var array = JArray.Parse(text); - // var array = api.Get().ToArray(); - // Assert.Equal("value2", array[1]); - // } - - - - // [Fact] - // public void TestValuesDelete() - // { - // api.Delete(1); - // } - //} - - public class ValuesFixture : Fonlow.Testing.DefaultHttpClient - { - public ValuesFixture() - { - Api = new Values(base.HttpClient, base.BaseUri); - } - - public Values Api { get; private set; } - } - - public class ValuesWithProxyFixture : Fonlow.Testing.DefaultHttpClient - { - public ValuesWithProxyFixture(): base(handler) - { - Api = new Values(base.HttpClient, base.BaseUri); - } - - static readonly HttpMessageHandler handler = new HttpClientHandler() - { - Proxy = new System.Net.WebProxy() - { - Address = new Uri("http://localhost:8888"), // Talk to proxy of Fiddler. Whether Fiddler is capturing traffic does not matter. - BypassProxyOnLocal = false, - //UseDefaultCredentials = proxyCredentials == null ? true : false, - //Credentials = proxyCredentials, - }, - - UseProxy = true, - - }; - - public Values Api { get; private set; } - } - - public partial class Values - { - - private System.Net.Http.HttpClient client; - - private System.Uri baseUri; - - public Values(System.Net.Http.HttpClient client, System.Uri baseUri) - { - if (client == null) - throw new ArgumentNullException("client", "Null HttpClient."); - - if (baseUri == null) - throw new ArgumentNullException("baseUri", "Null baseUri"); - - this.client = client; - this.baseUri = baseUri; - } - - /// - /// DELETE api/Values/{id} - /// - public async Task DeleteAsync(int id) - { - var requestUri = new Uri(this.baseUri, "api/Values/" + id); - var responseMessage = await client.DeleteAsync(requestUri); - responseMessage.EnsureSuccessStatusCode(); - } - - /// - /// DELETE api/Values/{id} - /// - public void Delete(int id) - { - var requestUri = new Uri(this.baseUri, "api/Values/" + id); - var responseMessage = this.client.DeleteAsync(requestUri).Result; - responseMessage.EnsureSuccessStatusCode(); - } - - /// - /// GET api/Values - /// - public async Task GetAsync() - { - var requestUri = new Uri(this.baseUri, "api/Values"); - var responseMessage = await client.GetAsync(requestUri); - responseMessage.EnsureSuccessStatusCode(); - var stream = await responseMessage.Content.ReadAsStreamAsync(); - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - var serializer = new JsonSerializer(); - return serializer.Deserialize(jsonReader); - } - } - - /// - /// GET api/Values - /// - public string[] Get() - { - var requestUri = new Uri(this.baseUri, "api/Values"); - var responseMessage = this.client.GetAsync(requestUri).Result; - responseMessage.EnsureSuccessStatusCode(); - var stream = responseMessage.Content.ReadAsStreamAsync().Result; - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - var serializer = new JsonSerializer(); - return serializer.Deserialize(jsonReader); - } - } - - /// - /// GET api/Values/{id}?name={name} - /// - public async Task GetAsync(int id, string name) - { - var requestUri = new Uri(this.baseUri, "api/Values/" + id + "?name=" + Uri.EscapeDataString(name)); - var responseMessage = await client.GetAsync(requestUri); - responseMessage.EnsureSuccessStatusCode(); - var stream = await responseMessage.Content.ReadAsStreamAsync(); - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - return jsonReader.ReadAsString(); - } - } - - /// - /// GET api/Values/{id}?name={name} - /// - public string Get(int id, string name) - { - var requestUri = new Uri(this.baseUri, "api/Values/" + id + "?name=" + Uri.EscapeDataString(name)); - var responseMessage = this.client.GetAsync(requestUri).Result; - responseMessage.EnsureSuccessStatusCode(); - var stream = responseMessage.Content.ReadAsStreamAsync().Result; - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - return jsonReader.ReadAsString(); - } - } - - /// - /// GET api/Values?name={name} - /// - public async Task GetAsync(string name) - { - var requestUri = new Uri(this.baseUri, "api/Values?name=" + Uri.EscapeDataString(name)); - var responseMessage = await client.GetAsync(requestUri); - responseMessage.EnsureSuccessStatusCode(); - var stream = await responseMessage.Content.ReadAsStreamAsync(); - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - return jsonReader.ReadAsString(); - } - } - - /// - /// GET api/Values?name={name} - /// - public string Get(string name) - { - var requestUri = new Uri(this.baseUri, "api/Values?name=" + Uri.EscapeDataString(name)); - var responseMessage = this.client.GetAsync(requestUri).Result; - responseMessage.EnsureSuccessStatusCode(); - var stream = responseMessage.Content.ReadAsStreamAsync().Result; - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - return jsonReader.ReadAsString(); - } - } - - /// - /// GET api/Values/{id} - /// - public async Task GetAsync(int id) - { - var requestUri = new Uri(this.baseUri, "api/Values/" + id); - var responseMessage = await client.GetAsync(requestUri); - responseMessage.EnsureSuccessStatusCode(); - var stream = await responseMessage.Content.ReadAsStreamAsync(); - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - return jsonReader.ReadAsString(); - } - } - - /// - /// GET api/Values/{id} - /// - public string Get(int id) - { - var requestUri = new Uri(this.baseUri, "api/Values/" + id); - var responseMessage = this.client.GetAsync(requestUri).Result; - responseMessage.EnsureSuccessStatusCode(); - var stream = responseMessage.Content.ReadAsStreamAsync().Result; - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - return jsonReader.ReadAsString(); - } - } - - /// - /// POST api/Values - /// - public async Task PostAsync(string value) - { - var requestUri = new Uri(this.baseUri, "api/Values"); - using (var requestWriter = new System.IO.StringWriter()) - { - var requestSerializer = JsonSerializer.Create(); - requestSerializer.Serialize(requestWriter, value); - var content = new StringContent(requestWriter.ToString(), System.Text.Encoding.UTF8, "application/json"); - var responseMessage = await client.PostAsync(requestUri, content); - responseMessage.EnsureSuccessStatusCode(); - var stream = await responseMessage.Content.ReadAsStreamAsync(); - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - return jsonReader.ReadAsString(); - } - } - } - - /// - /// POST api/Values - /// - public string Post(string value) - { - var requestUri = new Uri(this.baseUri, "api/Values"); - using (var requestWriter = new System.IO.StringWriter()) - { - var requestSerializer = JsonSerializer.Create(); - requestSerializer.Serialize(requestWriter, value); - var content = new StringContent(requestWriter.ToString(), System.Text.Encoding.UTF8, "application/json"); - var responseMessage = this.client.PostAsync(requestUri, content).Result; - responseMessage.EnsureSuccessStatusCode(); - var stream = responseMessage.Content.ReadAsStreamAsync().Result; - using (JsonReader jsonReader = new JsonTextReader(new System.IO.StreamReader(stream))) - { - return jsonReader.ReadAsString(); - } - } - } - - /// - /// PUT api/Values/{id} - /// - public async Task PutAsync(int id, string value) - { - var requestUri = new Uri(this.baseUri, "api/Values/" + id); - using (var requestWriter = new System.IO.StringWriter()) - { - var requestSerializer = JsonSerializer.Create(); - requestSerializer.Serialize(requestWriter, value); - var content = new StringContent(requestWriter.ToString(), System.Text.Encoding.UTF8, "application/json"); - var responseMessage = await client.PutAsync(requestUri, content); - responseMessage.EnsureSuccessStatusCode(); - } - } - - /// - /// PUT api/Values/{id} - /// - public void Put(int id, string value) - { - var requestUri = new Uri(this.baseUri, "api/Values/" + id); - using (var requestWriter = new System.IO.StringWriter()) - { - var requestSerializer = JsonSerializer.Create(); - requestSerializer.Serialize(requestWriter, value); - var content = new StringContent(requestWriter.ToString(), System.Text.Encoding.UTF8, "application/json"); - var responseMessage = this.client.PutAsync(requestUri, content).Result; - responseMessage.EnsureSuccessStatusCode(); - } - } - } - -} diff --git a/Tests/WebApiTestsCore/WebApiTestsCore.csproj b/Tests/WebApiTestsCore/WebApiTestsCore.csproj deleted file mode 100644 index 13da174..0000000 --- a/Tests/WebApiTestsCore/WebApiTestsCore.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - net8.0 - - false - - - - - - - - - PreserveNewest - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/Tests/WebApiTestsCore/appsettings.json b/Tests/WebApiTestsCore/appsettings.json deleted file mode 100644 index 8a45055..0000000 --- a/Tests/WebApiTestsCore/appsettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Testing": { - "BaseUrl": "http://localhost:60921/", - "HostSite": "DemoWebApi", - "HostSiteApplicationPool": "Clr4IntegratedAppPool", - "SlnName": "FonlowTesting", - "SlnRoot": "SLN_ROOT_.VS" - - } -} \ No newline at end of file