@@ -339,32 +339,33 @@ let ``ObjectListFilter works with getDiscriminator and getDiscriminatorValue for
339339 c.Name |> equals " Complex AA"
340340 | _ -> failwith " Expected Complex"
341341
342- type Cow = { ID : int ; Name : string ; Discriminator : string ; __typename : string }
342+ // Dummy types to be used in OfType filter
343+ type Cow = class end
344+ type Horse = class end
345+ type Hamster = class end
343346
344- type Horse = { ID : int ; Name : string ; Discriminator : string ; __typename : string }
345-
346- type Hamster = { ID : int ; Name : string ; Discriminator : string ; __typename : string }
347+ type Animal = { ID : int ; Name : string ; Discriminator : string ; __typename : string }
347348
348349let animalData = [
349- { ID = 1 ; Discriminator = " Cow" ; Name = " Cow A" ; __ typename = typeof < Cow>. Name }
350+ { ID = 1 ; Discriminator = " Cow" ; Name = " Cow A" ; __ typename = " Cow" }
350351 {
351352 ID = 2
352353 Discriminator = " Horse"
353354 Name = " Horse B"
354- __ typename = typeof < Horse>. Name
355+ __ typename = " Horse"
355356 }
356- { ID = 3 ; Discriminator = " Cow" ; Name = " Cow C" ; __ typename = typeof < Cow>. Name }
357+ { ID = 3 ; Discriminator = " Cow" ; Name = " Cow C" ; __ typename = " Cow" }
357358 {
358359 ID = 4
359360 Discriminator = " Horse"
360361 Name = " Horse D"
361- __ typename = typeof < Horse>. Name
362+ __ typename = " Horse"
362363 }
363364 {
364365 ID = 5
365366 Discriminator = " Hamster"
366367 Name = " Hamster E"
367- __ typename = typeof < Hamster>. Name
368+ __ typename = " Hamster"
368369 }
369370]
370371
@@ -383,17 +384,13 @@ let ``ObjectListFilter works with getDiscriminatorValue for Horse`` () =
383384 let filteredData = queryable.Apply ( filter, options) |> Seq.toList
384385 List.length filteredData |> equals 2
385386 do
386- let result = List.head filteredData
387- match result with
388- | h ->
389- h.ID |> equals 2
390- h.Name |> equals " Horse B"
387+ let animal = List.head filteredData
388+ animal.ID |> equals 2
389+ animal.Name |> equals " Horse B"
391390 do
392- let result = List.last filteredData
393- match result with
394- | h ->
395- h.ID |> equals 4
396- h.Name |> equals " Horse D"
391+ let animal = List.last filteredData
392+ animal.ID |> equals 4
393+ animal.Name |> equals " Horse D"
397394
398395[<Fact>]
399396let ``ObjectListFilter works with getDiscriminatorValue startsWith for Horse and Hamster`` () =
@@ -406,23 +403,19 @@ let ``ObjectListFilter works with getDiscriminatorValue startsWith for Horse and
406403 ( function
407404 | t when t = typeof< Cow> -> t.Name
408405 | t when t = typeof< Horse> -> t.Name
409- | t when t = typeof< Hamster > -> t.Name
406+ | t when t = typeof< Animal > -> t.Name
410407 | _ -> raise ( NotSupportedException " Type not supported" ))
411408 )
412409 let filteredData = queryable.Apply ( filter, options) |> Seq.toList
413410 List.length filteredData |> equals 3
414411 do
415- let result = List.head filteredData
416- match result with
417- | c ->
418- c.ID |> equals 2
419- c.Name |> equals " Horse B"
412+ let animal = List.head filteredData
413+ animal.ID |> equals 2
414+ animal.Name |> equals " Horse B"
420415 do
421- let result = List.last filteredData
422- match result with
423- | c ->
424- c.ID |> equals 5
425- c.Name |> equals " Hamster E"
416+ let animal = List.last filteredData
417+ animal.ID |> equals 5
418+ animal.Name |> equals " Hamster E"
426419
427420type ListTagsProduct = { Name : string ; Tags : string list }
428421
@@ -505,14 +498,10 @@ let ``ObjectListFilter OfTypes works with two or more types`` () =
505498 let filteredData = queryable.Apply ( filter, options) |> Seq.toList
506499 List.length filteredData |> equals 4
507500 do
508- let result = List.head filteredData
509- match result with
510- | c ->
511- c.ID |> equals 1
512- c.Name |> equals " Cow A"
501+ let animal = List.head filteredData
502+ animal.ID |> equals 1
503+ animal.Name |> equals " Cow A"
513504 do
514- let result = List.last filteredData
515- match result with
516- | h ->
517- h.ID |> equals 4
518- h.Name |> equals " Horse D"
505+ let animal = List.last filteredData
506+ animal.ID |> equals 4
507+ animal.Name |> equals " Horse D"
0 commit comments