Skip to content

Commit

Permalink
update failing test init and class init methods
Browse files Browse the repository at this point in the history
  • Loading branch information
marabooy committed Feb 4, 2020
1 parent d38a97e commit 8014da3
Showing 1 changed file with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

<CLSCompliant(False)>
Public Class MyAllTypes1
Inherits AllTypes
Expand Down Expand Up @@ -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.
Expand All @@ -99,14 +102,16 @@ 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

'<TestCleanup()> Public Sub PerTestCleanup()
'End Sub

<TestCategory("Partition3")> <TestMethod()>
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
Expand All @@ -118,9 +123,7 @@ Partial Public Class ClientModule

<TestCategory("Partition3")> <TestMethod()>
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,
Expand All @@ -137,9 +140,7 @@ Partial Public Class ClientModule

<TestCategory("Partition3")> <TestMethod()>
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
Expand All @@ -150,9 +151,7 @@ Partial Public Class ClientModule

<TestCategory("Partition3")> <TestMethod()>
Public Sub ApiContextGetMetadataUri_NullBaseUri_Error()
Dim context = New DataServiceContext()
'context.EnableAtom = True
'context.Format.UseAtom()

Dim act As Action = Sub()
context.GetMetadataUri()
End Sub
Expand All @@ -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,
Expand All @@ -180,21 +178,19 @@ Partial Public Class ClientModule

<TestCategory("Partition3")> <TestMethod()>
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")

End Sub

<TestCategory("Partition3")> <TestMethod()>
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")
Expand Down Expand Up @@ -224,9 +220,7 @@ Partial Public Class ClientModule
<TestCategory("Partition3")> <TestMethod()>
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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -525,7 +520,7 @@ Partial Public Class ClientModule
<TestCategory("Partition3")> <TestMethod()>
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,
Expand Down

0 comments on commit 8014da3

Please sign in to comment.