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

Use BinaryHttpDomainClient in AspNetCore Test #471

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -260,5 +260,12 @@ public static WebException ExpectWebException(GenericDelegate del, string messag
Assert.AreEqual(webExceptionStatus, e.Status);
return e;
}

public static InvalidCastException ExpectInvalidCastException(GenericDelegate del, string message)
{
InvalidCastException e = ExpectExceptionHelper<InvalidCastException>(del);
Assert.AreEqual(message, e.Message);
return e;
}
}
}
8 changes: 0 additions & 8 deletions src/Test/OpenRiaservices.EndToEnd.AspNetCore.Test/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ public static void AssemblyInit(TestContext context)
UseCookies = true,
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
});
#if NETFRAMEWORK
#pragma warning disable CS0618 // Type or member is obsolete
DomainContext.DomainClientFactory = new Web.WebDomainClientFactory()
{
ServerBaseUri = TestURIs.RootURI,
};
#pragma warning restore CS0618 // Type or member is obsolete
#endif

// Note: Below gives errors when running (at least BinaryHttpDomainClientFactory) against AspNetCore
// It seems to cache results even with "private, no-store"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ public void TestInvalidProviderName()
/// Verify that if an invalid DomainOperationEntry name is specified, that the Load
/// operation finishes with the expected WebResponse.StatusCode.
/// </summary>
#if ASPNETCORE
[Ignore("BinaryHttpDomainClientFactory does not validate if method exists, and since name is always specified by code generation it is not important to validate it")]
#endif
[TestMethod]
public void TestInvalidMethodName()
{
Expand Down
15 changes: 13 additions & 2 deletions src/Test/OpenRiaservices.EndToEnd.Wcf.Test/Data/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1952,12 +1952,19 @@ public void TestDomainOperationEntry_IncorrectParameterType()
paramValues["subCategoryID"] = "Foobar";
paramValues["minListPrice"] = 50;
paramValues["color"] = "Yellow";

#if ASPNETCORE
ExceptionHelper.ExpectInvalidCastException(delegate
{
var query = ctxt.CreateQuery<Product>("GetProductsMultipleParams", paramValues, false, true);
ctxt.Load(query, false);
}, "Specified cast is not valid.");
#else
ExceptionHelper.ExpectArgumentException(delegate
{
var query = ctxt.CreateQuery<Product>("GetProductsMultipleParams", paramValues, false, true);
ctxt.Load(query, false);
}, "Object of type 'System.String' cannot be converted to type 'System.Int32'.");
#endif
}

/// <summary>
Expand Down Expand Up @@ -1999,14 +2006,18 @@ await ValidateQueryException(ctxt, query, ex =>
});
}

#if ASPNETCORE
[Ignore("BinaryHttpDomainClientFactory does not validate if method exists, and since name is always specified by code generation it is not important to validate it")]
#endif
[TestMethod]
public async Task TestServerExceptions_QueryOnNonExistentMethod()
{
TestDataContext ctxt = new TestDataContext(new Uri(TestURIs.RootURI, "TestDomainServices-TestCatalog1.svc"));
var query = ctxt.CreateQuery<Product>("NonExistentMethod", null, false, true);
await ValidateQueryException(ctxt, query, ex =>
{
// REVIEW: Assert the error message.
Assert.IsTrue(ex.Message.StartsWith("Load operation failed for query 'NonExistentMethod'. An error occurred while receiving the HTTP response to"));
Assert.IsTrue(ex.Message.EndsWith("This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details."));
Assert.IsNotNull(ex.InnerException as CommunicationException, "Expected CommunicationException");
Assert.IsNotNull(ex.InnerException.InnerException as WebException, "Expected WebException");
});
Expand Down