Skip to content

Add unit tests for the query and command builders #17

Open

Description

@hazeliscoding

Neither builder has a test. The 7 existing tests cover the client constructor, QueryRecords and QuickbaseResult. Builder tests don't need the HTTP mock: build a request and assert on the object you get back.

What to do

Add QuickbaseQueryBuilderTests.cs and QuickbaseCommandBuilderTests.cs under QuickbaseNet.UnitTests/Tests/, in the style of the existing tests. Cover at least:

  • Build() copies From, Select and Where into the request.
  • SortBy and GroupBy called twice keep both items, in order.
  • Select called twice keeps only the last list.
  • With nothing set, SortBy, GroupBy and Options are null.
  • AddNewRecord twice gives two entries in Data, and ReturnFields ends up in FieldsToReturn.
  • UpdateRecord(8, ...) adds field "3" with the string value "8" next to the configured fields.
  • AddFields sets every field, and AddField twice on one ID keeps the last value.
  • BuildDeleteCommand maps ForTable to From and WithDeletionCriteria to Where.

Test what the builders do today. If something looks wrong, say so in the PR instead of changing the builder.

Where to look

  • QuickbaseNet/Helpers/QuickbaseQueryBuilder.cs
  • QuickbaseNet/Helpers/QuickbaseCommandBuilder.cs (field 3 is set at line 65)
  • QuickbaseNet.UnitTests/Tests/QuickbaseClientTests.cs for style

Done when

  • Every case above has a passing test
  • Nothing under QuickbaseNet/ changes

Testing it

dotnet test --filter FullyQualifiedName~BuilderTests

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions