From d937383c78243f2c0c8117686267d2d7996d2861 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Mon, 29 Jul 2024 13:46:30 +0200 Subject: [PATCH] test: Legacy.Client getestet und erfolgreich abgeschlossen, alle erforderlichen Tests bestanden --- .../packages.config | 1 + .../Client/BaseHttpClientServiceTests.cs | 60 ++++++++++ .../DigitalData.Core.Legacy.Tests.csproj | 107 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 20 ++++ DigitalData.Core.Legacy.Tests/app.config | 11 ++ DigitalData.Core.Legacy.Tests/packages.config | 16 +++ DigitalData.Core.sln | 6 + 7 files changed, 221 insertions(+) create mode 100644 DigitalData.Core.Legacy.Tests/Client/BaseHttpClientServiceTests.cs create mode 100644 DigitalData.Core.Legacy.Tests/DigitalData.Core.Legacy.Tests.csproj create mode 100644 DigitalData.Core.Legacy.Tests/Properties/AssemblyInfo.cs create mode 100644 DigitalData.Core.Legacy.Tests/app.config create mode 100644 DigitalData.Core.Legacy.Tests/packages.config diff --git a/DigitalData.Core.Client.Legacy/packages.config b/DigitalData.Core.Client.Legacy/packages.config index 1e8af40..ac58b05 100644 --- a/DigitalData.Core.Client.Legacy/packages.config +++ b/DigitalData.Core.Client.Legacy/packages.config @@ -1,6 +1,7 @@  + diff --git a/DigitalData.Core.Legacy.Tests/Client/BaseHttpClientServiceTests.cs b/DigitalData.Core.Legacy.Tests/Client/BaseHttpClientServiceTests.cs new file mode 100644 index 0000000..ebcdd1f --- /dev/null +++ b/DigitalData.Core.Legacy.Tests/Client/BaseHttpClientServiceTests.cs @@ -0,0 +1,60 @@ +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using DigitalData.Core.Legacy.Client; +using Microsoft.Extensions.DependencyInjection; + +namespace DigitalData.Core.Legacy.Tests.Client +{ + [TestClass] + public class BaseHttpClientServiceTests + { + private BaseHttpClientService _service; + + [ClassInitialize] + public static void ClassSetUp(TestContext context) + { + ServiceFactory.Services + .AddHttpClientService("https://jsonplaceholder.typicode.com/todos") + .BuildServiceProvider(); + } + + [TestInitialize] + public void SetUp() + { + _service = ServiceFactory.Provide(); + } + + [TestMethod] + public async Task FetchJsonAsync_ShouldReturnJsonResponseAsDynamic() + { + // Act + var expectedUserId = (int)await _service.FetchAsync("/1", sendWithCookie: false, saveCookie: false) + .ThenAsync(res => res.Json()) + .ThenAsync(todo => todo.userId); + + // Assert + Assert.AreEqual(1, expectedUserId, "The userId of the fetched JSON object should be 1."); + } + + [TestMethod] + public async Task FetchJsonAsync_ShouldReturnJsonResponse() + { + // Act + var expectedUserId = await _service.FetchAsync("/1", sendWithCookie: false, saveCookie: false) + .ThenAsync(res => res.Json()) + .ThenAsync(todo => todo.UserId); + + // Assert + Assert.AreEqual(1, expectedUserId, "The userId of the fetched JSON object should be 1."); + } + } + + public class Todo + { + public int UserId { get; set; } + public int Id { get; set; } + public string Title { get; set; } + public bool Completed { get; set; } + } + +} \ No newline at end of file diff --git a/DigitalData.Core.Legacy.Tests/DigitalData.Core.Legacy.Tests.csproj b/DigitalData.Core.Legacy.Tests/DigitalData.Core.Legacy.Tests.csproj new file mode 100644 index 0000000..c8543f7 --- /dev/null +++ b/DigitalData.Core.Legacy.Tests/DigitalData.Core.Legacy.Tests.csproj @@ -0,0 +1,107 @@ + + + + + + Debug + AnyCPU + {84B18026-F9A0-4366-BC69-1662D9E7342D} + Library + Properties + DigitalData.Core.Legacy.Tests + DigitalData.Core.Legacy.Tests + v4.6.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + + ..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + ..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + + + + + + + + + + + {e009a053-a9f4-48f2-984f-ef5c376a9b14} + DigitalData.Core.Legacy.Client + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/DigitalData.Core.Legacy.Tests/Properties/AssemblyInfo.cs b/DigitalData.Core.Legacy.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c858f51 --- /dev/null +++ b/DigitalData.Core.Legacy.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("DigitalData.Core.Legacy.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Digital Data GmbH")] +[assembly: AssemblyProduct("DigitalData.Core.Legacy.Tests")] +[assembly: AssemblyCopyright("Copyright © Digital Data GmbH 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("84b18026-f9a0-4366-bc69-1662d9e7342d")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DigitalData.Core.Legacy.Tests/app.config b/DigitalData.Core.Legacy.Tests/app.config new file mode 100644 index 0000000..9901ce9 --- /dev/null +++ b/DigitalData.Core.Legacy.Tests/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/DigitalData.Core.Legacy.Tests/packages.config b/DigitalData.Core.Legacy.Tests/packages.config new file mode 100644 index 0000000..794f3e0 --- /dev/null +++ b/DigitalData.Core.Legacy.Tests/packages.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DigitalData.Core.sln b/DigitalData.Core.sln index 00b72c9..2391185 100644 --- a/DigitalData.Core.sln +++ b/DigitalData.Core.sln @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DigitalData.Core.Abstractio EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.Core.Legacy.Client", "DigitalData.Core.Client.Legacy\DigitalData.Core.Legacy.Client.csproj", "{E009A053-A9F4-48F2-984F-EF5C376A9B14}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalData.Core.Legacy.Tests", "DigitalData.Core.Legacy.Tests\DigitalData.Core.Legacy.Tests.csproj", "{84B18026-F9A0-4366-BC69-1662D9E7342D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -56,6 +58,10 @@ Global {E009A053-A9F4-48F2-984F-EF5C376A9B14}.Debug|Any CPU.Build.0 = Debug|Any CPU {E009A053-A9F4-48F2-984F-EF5C376A9B14}.Release|Any CPU.ActiveCfg = Release|Any CPU {E009A053-A9F4-48F2-984F-EF5C376A9B14}.Release|Any CPU.Build.0 = Release|Any CPU + {84B18026-F9A0-4366-BC69-1662D9E7342D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84B18026-F9A0-4366-BC69-1662D9E7342D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84B18026-F9A0-4366-BC69-1662D9E7342D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84B18026-F9A0-4366-BC69-1662D9E7342D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE