Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspnetcore tests #384

Merged
merged 31 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
75319ba
Add separatate test projects for end to end tests
Daniel-Svensson Nov 5, 2022
97a05a9
Exclude som tests from aspnetcore E2E
Daniel-Svensson Nov 5, 2022
0bf9851
Set debug environment during tests to get better error messages
Daniel-Svensson Nov 7, 2022
1d1d7ef
Make WebDomainClientTests_Globalization use WebDomainClient
Daniel-Svensson Nov 8, 2022
36411d9
Merge remote-tracking branch 'upstream/main' into aspnetcore_tests
Daniel-Svensson Feb 13, 2023
a2e4580
move non e2e test class to client tests
Daniel-Svensson Apr 24, 2023
c2363e0
Merge remote-tracking branch 'upstream/main' into aspnetcore_tests
Daniel-Svensson Jun 20, 2023
eb7ec70
Merge remote-tracking branch 'upstream/main' into aspnetcore_tests
Daniel-Svensson Jun 20, 2023
f36e4a4
Fix a few aspnetcore tests taking in binary as aparameter
Daniel-Svensson Jul 3, 2023
dd7ea84
Prepare shared client tests on net6 as well
Daniel-Svensson Jul 3, 2023
4e4558f
fix implicit cast for fake binary impl
Daniel-Svensson Jul 3, 2023
439c505
Disable caching to avoid problems with caching and AspNetCore
Daniel-Svensson Jul 4, 2023
592d071
Merge remote-tracking branch 'upstream/main' into aspnetcore_tests
Daniel-Svensson Aug 29, 2023
99a0ff2
move more files to "shared" tests
Daniel-Svensson Aug 29, 2023
399f018
Run shared client tests on net6 as well
Daniel-Svensson Aug 29, 2023
e75100d
prepare net6 versions of end to end tests
Daniel-Svensson Aug 29, 2023
29debe1
Merge remote-tracking branch 'upstream/aspnetcore_tests' into aspnetc…
Daniel-Svensson Aug 29, 2023
2759568
Setup working directory and ensure that aspnetcore website can find d…
Daniel-Svensson Aug 29, 2023
8e73fad
prepare vbtests for net6
Daniel-Svensson Aug 29, 2023
5ba07b4
hard coe net6 in dependency
Daniel-Svensson Aug 29, 2023
625c1e3
Update azure-pipelines.yml for Azure Pipelines
Daniel-Svensson Aug 30, 2023
cdde1b2
Fix Client.VbTests (it does E2E and needs that startup logic)
Daniel-Svensson Aug 31, 2023
ebc5866
remove cachine and WCF specific tests from ASPNETCORE endpoint
Daniel-Svensson Aug 31, 2023
1a3c7a0
Add AuthenticationService1 to aspnetcore tests so LoginThenLogout tes…
Daniel-Svensson Aug 31, 2023
04db478
Make many of tests Uri's relative
Daniel-Svensson Aug 31, 2023
65031d9
Rewrite WebDomainClientTestsSimple so it works with any type of Domai…
Daniel-Svensson Aug 31, 2023
c2a7be7
disable additional test but add todo about how it can be fixed
Daniel-Svensson Aug 31, 2023
c82c071
Update azure-pipelines.yml for Azure Pipelines
Daniel-Svensson Aug 31, 2023
f4304db
Fix DomainContext_Submit_ValidationErrorOnServer test after test proj…
Daniel-Svensson Sep 2, 2023
f548bab
temp fix for
Daniel-Svensson Sep 2, 2023
f822a3c
update aspnetcore TODO
Daniel-Svensson Sep 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BinaryHttpDomainClientFactory
/// Create a <see cref="BinaryHttpDomainClientFactory"/> where all requests share a single <see cref="HttpMessageHandler"/>
/// <para>IMPORTANT: To handle DNS updates you need to configure <c>System.Net.ServicePointManager.ConnectionLeaseTimeout</c> on .Net framework</para>
/// </summary>
/// <param name="serverBaseUri">The value base all service Uris on (see <see cref="ServerBaseUri"/>)</param>
/// <param name="serverBaseUri">The value base all service Uris on (see <see cref="DomainClientFactory.ServerBaseUri"/>)</param>
/// <param name="messageHandler"><see cref="HttpMessageHandler"/> to be shared by all requests,
/// if uncertain create a <see cref="HttpClientHandler"/> and enable cookies and compression</param>
public BinaryHttpDomainClientFactory(Uri serverBaseUri, HttpMessageHandler messageHandler)
Expand All @@ -28,7 +28,7 @@ public BinaryHttpDomainClientFactory(Uri serverBaseUri, HttpMessageHandler messa
/// <summary>
/// Constructor intended for .Net Core where the actual creation is handled by <c>IHttpClientFactory</c> or similar
/// </summary>
/// <param name="serverBaseUri">The value base all service Uris on (see <see cref="ServerBaseUri"/>)</param>
/// <param name="serverBaseUri">The value base all service Uris on (see <see cref="DomainClientFactory.ServerBaseUri"/>)</param>
/// <param name="httpClientFactory">method creating a new HttpClient each time, should never return null</param>
public BinaryHttpDomainClientFactory(Uri serverBaseUri, Func<HttpClient> httpClientFactory)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
[assembly: InternalsVisibleTo("OpenRiaServices.Client.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
[assembly: InternalsVisibleTo("OpenRiaServices.Client.Vb.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
[assembly: InternalsVisibleTo("OpenRiaServices.Client.Web.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
[assembly: InternalsVisibleTo("OpenRiaservices.EndToEnd.AspNetCore.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
[assembly: InternalsVisibleTo("OpenRiaservices.EndToEnd.Wcf.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
[assembly: InternalsVisibleTo("OpenRiaServices.Client.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
[assembly: InternalsVisibleTo("OpenRiaServices.Client.Vb.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
[assembly: InternalsVisibleTo("OpenRiaServices.Controls.DomainServices.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]

[assembly: InternalsVisibleTo("OpenRiaservices.EndToEnd.AspNetCore.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
[assembly: InternalsVisibleTo("OpenRiaservices.EndToEnd.Wcf.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006165f2d838c2494ed8ed9644fbc060f22fea4941d552916f6ca7078f64b7d5a6053ff36e63eb312fa909ae4223e8393d20eed67217e46747cebb6fa5b348738c5785568d642b0bf499f7863829242e655372773636d6c974d2d5abd97c57640893f7dd390cfd1015268ee85611f51c71068e8a15a829a97ea9dad46d1619b3b0")]
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ namespace OpenRiaServices.Client.Authentication.Test
/// Tests <see cref="AuthenticationService"/> members.
/// </summary>
[TestClass]
#if !NETFRAMEWORK
[Ignore("xxxCancel methods seems to hang on net6")]
#endif
public class AuthenticationServiceTest : UnitTestBase
{
#region Mock AuthenticationService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,4 @@ private void TestNotifications(CatalogEntityContainer ec) {
Assert.AreEqual(1, NumNotifications);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenRiaServices.Silverlight.Testing;
using TestDomainServices;
using Cities;
using Description = Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute;

namespace OpenRiaServices.Client.Test
{
using Cities;
using Description = Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute;

[TestClass]
public class EntityCollectionTests : UnitTestBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern alias DomainServices;
extern alias DomainServicesTests;
extern alias WebRia;
extern alias SSmDsWeb;
extern alias WebRia;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
Expand All @@ -11,11 +11,10 @@
using System.Threading;
using DataTests.AdventureWorks.LTS;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestDomainServices.LTS;
using VbExpressions;
using DomainServiceDescription = DomainServices::OpenRiaServices.Server.DomainServiceDescription;
using NorthwindDomainService = DomainServicesTests::TestDomainServices.LTS.Northwind;
using LinqResource = SSmDsWeb::OpenRiaServices.Client.Resources;
using NorthwindDomainService = DomainServicesTests::TestDomainServices.EFCore.Northwind;
using SystemLinqDynamic = WebRia::System.Linq.Dynamic;

namespace OpenRiaServices.Client.Test
Expand Down
34 changes: 8 additions & 26 deletions src/OpenRiaServices.Client/Test/Client.Test/Data/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,6 @@ namespace OpenRiaServices.Client.Test

public static class TestHelperMethods
{
/// <summary>
/// Perform a submit on the specified context using the DomainClient directy. This bypasses all context operations,
/// validation, etc.
/// </summary>
/// <param name="ctxt">The context to submit on</param>
/// <param name="callback">The callback to execute when the submit completes</param>
public static void SubmitDirect(DomainContext ctxt, Action<SubmitCompletedResult> callback)
{
EntityChangeSet cs = ctxt.EntityContainer.GetChanges();
Debug.Assert(!cs.IsEmpty, "No changes to submit!");


SynchronizationContext syncContext = SynchronizationContext.Current ?? new SynchronizationContext();

ctxt.DomainClient.SubmitAsync(cs, CancellationToken.None)
.ContinueWith(task =>
{
SubmitCompletedResult submitResults = task.GetAwaiter().GetResult();
syncContext.Post(
delegate
{
callback(submitResults);
},
null);
});
}

/// <summary>
/// Method used to turn property level validation on or off for an entity. This allows invalid
Expand Down Expand Up @@ -127,6 +101,14 @@ public static bool VerifyEntityState(IDictionary<string, object> expectedState,
}
}

public class ConfigurableEntityContainer : EntityContainer
{
public void CreateSet<TEntity>(EntitySetOperations operations) where TEntity : Entity, new()
{
base.CreateEntitySet<TEntity>(operations);
}
}

/// <summary>
/// Class that provides/caches database data without performing any remote queries.
/// </summary>
Expand Down
46 changes: 1 addition & 45 deletions src/OpenRiaServices.Client/Test/Client.Test/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,22 @@
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using httpDomainClient::OpenRiaServices.Client.DomainClients;
using OpenRiaServices.Common.Test;

namespace OpenRiaServices.Client.Test
{
[TestClass()]
public sealed class Main
{
private static IISExpressWebserver s_webServer = null;

[AssemblyInitialize()]
public static void AssemblyInit(TestContext context)
{
Thread.CurrentThread.CurrentUICulture
= Thread.CurrentThread.CurrentCulture
= new System.Globalization.CultureInfo("en-US");

StartWebServer();

DomainContext.DomainClientFactory = new Web.WebDomainClientFactory()
{
ServerBaseUri = TestURIs.RootURI,
};

// Uncomment below to run tests using BinaryHttpDomainClientFactory instead:
//
//DomainContext.DomainClientFactory = new BinaryHttpDomainClientFactory(TestURIs.RootURI, new HttpClientHandler()
//{
// CookieContainer = new CookieContainer(),
// UseCookies = true,
// AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
//});

HttpWebRequest.DefaultCachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.Default);
}

[AssemblyCleanup]
public static void AssemblyCleanup()
{
#if !VBTests
// make sure our test database is removed on the server after all unit tests
// have been run
((IDisposable)UpdateTests.TestDatabase).Dispose();
#endif
s_webServer?.Stop();
}

private static void StartWebServer()
{
string projectPath = File.ReadAllLines("ClientTestProjectPath.txt")[0];
string webSitePath = Path.GetFullPath(Path.Combine(projectPath, @"..\..\..\Test\WebsiteFullTrust"));

if (!Directory.Exists(webSitePath))
throw new FileNotFoundException($"Website not found at {webSitePath}");
DomainContext.DomainClientFactory = new BinaryHttpDomainClientFactory(new Uri("https://localhost:21312/DOES_NOT_EXISTS"), new HttpClientHandler() {});
Dismissed Show dismissed Hide dismissed

s_webServer = new IISExpressWebserver();
#if VBTests
s_webServer.Start(webSitePath, 60000);
#else
s_webServer.Start(webSitePath, 60002);
#endif
}
}
}
Loading
Loading