From 8014da3ada837636b3f67b8e02564639fb596114 Mon Sep 17 00:00:00 2001 From: David Wambugu Date: Tue, 4 Feb 2020 19:55:50 +0300 Subject: [PATCH] update failing test init and class init methods --- .../ClientUnitTests/EntitySetResolverTests.vb | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/test/FunctionalTests/Tests/DataServices/UnitTests/ClientUnitTests/EntitySetResolverTests.vb b/test/FunctionalTests/Tests/DataServices/UnitTests/ClientUnitTests/EntitySetResolverTests.vb index 1bbf828efd..2fdc35e445 100644 --- a/test/FunctionalTests/Tests/DataServices/UnitTests/ClientUnitTests/EntitySetResolverTests.vb +++ b/test/FunctionalTests/Tests/DataServices/UnitTests/ClientUnitTests/EntitySetResolverTests.vb @@ -45,6 +45,8 @@ Partial Public Class ClientModule New Tuple(Of String, Uri)("Uri has Query", New Uri("http://foo/awesome.svc?id=10", UriKind.Absolute)), New Tuple(Of String, Uri)("Uri is Relative", New Uri("MySet", UriKind.Relative))} + Private context As DataServiceContext + Public Class MyAllTypes1 Inherits AllTypes @@ -75,6 +77,7 @@ Partial Public Class ClientModule streamContentWeb.ServiceType = GetType(AstoriaUnitTests.Stubs.StreamingContentService) streamContentWeb.StartService() Dim ctx = New DataServiceContext(streamingWeb.ServiceRoot) + ctx.Format.UseJson(New EdmModel()) ' Since we are sending $value payload, we must correctly set the accept type header. ' Otherwise, astoria server sends application/atom+xml as the header value and then client fails to parse. @@ -99,6 +102,8 @@ Partial Public Class ClientModule Me.northwindCtx = New NorthwindSimpleModel.NorthwindContext(northwindWeb.ServiceRoot) 'Me.northwindCtx.EnableAtom = True 'Me.northwindCtx.Format.UseAtom() + Me.context = New DataServiceContext() + context.Format.UseJson(New EdmModel()) End Sub ' Public Sub PerTestCleanup() @@ -106,7 +111,7 @@ Partial Public Class ClientModule Public Sub ApiContextBeginExecute_NullBaseUri_Error() - Dim context = New DataServiceContext() + Dim act As Action = Sub() context.BeginExecute(Of Object)(New Uri("MySet", UriKind.Relative), Sub(ar As IAsyncResult) Return, Nothing) End Sub @@ -118,9 +123,7 @@ Partial Public Class ClientModule Public Sub ApiContextBeginExecute_NullBaseUri_AbsoluteRequestUri_Success() - Dim context = New DataServiceContext() - 'context.EnableAtom = True - context.Format.UseJson(New EdmModel()) + context.BeginExecute(Of Object)(entitySet1AbsoluteUri, Sub(ar As IAsyncResult) CType(ar, DataServiceQuery(Of Object)).EndExecute(ar).ToList() End Sub, @@ -137,9 +140,7 @@ Partial Public Class ClientModule Public Sub ApiContextExecute_NullBaseUri_Error() - Dim context = New DataServiceContext() - 'context.EnableAtom = True - 'context.Format.UseAtom() + Dim act As Action = Sub() context.Execute(Of Object)(New Uri("MySet", UriKind.Relative)) End Sub @@ -150,9 +151,7 @@ Partial Public Class ClientModule Public Sub ApiContextGetMetadataUri_NullBaseUri_Error() - Dim context = New DataServiceContext() - 'context.EnableAtom = True - 'context.Format.UseAtom() + Dim act As Action = Sub() context.GetMetadataUri() End Sub @@ -169,7 +168,6 @@ Partial Public Class ClientModule Console.WriteLine("Running variation - " + variation.Item1) Dim act As Action = Sub() - Dim context = New DataServiceContext() context.BaseUri = variation.Item2 End Sub AssertUtil.RunCatch(Of InvalidOperationException)(act, @@ -180,11 +178,11 @@ Partial Public Class ClientModule Public Sub ApiContextBaseUriStateEquvilentBetweenDefaultCtorAndNullPassedToBaseUriCtor() - Dim context = New DataServiceContext() + 'context.EnableAtom = True 'context.Format.UseAtom() Dim contextNull = New DataServiceContext(Nothing) - + Assert.AreEqual(context.BaseUri, contextNull.BaseUri, "the base uri's should be equivelent") Assert.AreEqual(context.ResolveEntitySet, contextNull.ResolveEntitySet, "the base uri's should be equivelent") @@ -192,9 +190,7 @@ Partial Public Class ClientModule Public Sub ApiContextBaseUriProperty() - Dim context = New DataServiceContext() - 'context.EnableAtom = True - 'context.Format.UseAtom() + Assert.IsNull(context.BaseUri, "The BaseUri property didn't default to null") Dim absoluteUri As Uri = New Uri("http://foo.com/Awesome.svc") @@ -224,9 +220,7 @@ Partial Public Class ClientModule Public Sub ApiContextResolveEntitySetProperty() Const absoluteUri As String = "http://foo.com/Awesome.svc" - Dim context = New DataServiceContext() - 'context.EnableAtom = True - 'context.Format.UseAtom() + Dim esr As Func(Of String, Uri) = Function(setName As String) New Uri(absoluteUri) context.ResolveEntitySet = esr Assert.AreEqual(esr, context.ResolveEntitySet, "the ResolveEntitySet property didn't set properly") @@ -262,7 +256,6 @@ Partial Public Class ClientModule Console.WriteLine("Running variation - " + variation.Item1) Dim act As Action = Sub() - Dim context = New DataServiceContext() context.ResolveEntitySet = Function(setName As String) Dim uri = variation.Item2 Return uri @@ -285,7 +278,8 @@ Partial Public Class ClientModule Public Sub ApiContextResolveEntitySetProperty_Throws() ' we shouldn't catch or modify what the resolver is throwing Dim SetupContext As Func(Of DataServiceContext) = Function() - Dim context = New DataServiceContext + Dim context = New DataServiceContext() + context.Format.UseJson(New EdmModel()) context.ResolveEntitySet = Function(setName As String) Throw New MyTestException End Function @@ -319,7 +313,7 @@ Partial Public Class ClientModule context = New DataServiceContext(New Uri("http://mudd", UriKind.Absolute)) 'context.EnableAtom = True - 'context.Format.UseAtom() + context.Format.UseJson(New EdmModel()) Assert.IsNull(context.ResolveEntitySet, "The default value of the ResolveEntitySetProperty should be null") End Sub @@ -329,6 +323,7 @@ Partial Public Class ClientModule Dim context = New DataServiceContext(New Uri("http://foo/ReturnsNull")) 'context.EnableAtom = True 'context.Format.UseAtom() + context.Format.UseJson(New EdmModel()) context.ResolveEntitySet = Function(setName As String) Return Nothing End Function @@ -525,7 +520,7 @@ Partial Public Class ClientModule Public Sub NoBaseUriAndNoEntitySetResolverOnAddObject_Error() Dim act As Action = Sub() - Dim context As New DataServiceContext() + context.AddObject("foo", New MyAllTypes1()) End Sub AssertUtil.RunCatch(Of InvalidOperationException)(act,