Commits

Maxim Moiseev  committed 410d32a

cleanQuery test added

  • Participants
  • Parent commits 1b0f8f8

Comments (0)

Files changed (1)

File src/VkontakteAPI/Linq2vk.Tests/ApiTests.fs

         let expected = "4a5bf45c9fe5c66d3afa73d8520fe46a"
         Assert.AreEqual(expected, actual)
 
+    member private this.IsNone = function
+        | None -> ()
+        | Some _ -> Assert.Fail("Is not None")
 
+    member private this.IsSome = function
+        | Some _ -> ()
+        | None -> Assert.Fail("Is None")
 
+    [<Test>]
+    member this.CleanQueryTest () =
+        let query = Query.fromSeq [
+                        // should be cleaned
+                        ("format", "JSON");
+                        ("api_id", "1854119");
+                        ("sig", "");
+                        ("sid", "");
+                        ("v", "3.0");
+                        // should remain
+                        ("method", "getProfiles");
+                        ("fields", "photo,sex");
+                    ]
+        let resultQ = Api.HelperFunctions.cleanQuery query
+        let (Query.Query kvs) = resultQ
+
+        this.IsNone <| List.tryFind (fun (k, _) -> k = "api_id") kvs
+        this.IsNone <| List.tryFind (fun (k, _) -> k = "format") kvs
+        this.IsNone <| List.tryFind (fun (k, _) -> k = "v") kvs
+        this.IsNone <| List.tryFind (fun (k, _) -> k = "sig") kvs
+        this.IsNone <| List.tryFind (fun (k, _) -> k = "sid") kvs
+
+        this.IsSome <| List.tryFind (fun (k, _) -> k = "method") kvs
+        this.IsSome <| List.tryFind (fun (k, _) -> k = "fields") kvs
+
+