bool operator==(const read_preference& lhs, const read_preference& rhs) {
    return (lhs.mode() == rhs.mode()) && (lhs.tags() == rhs.tags());
}
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "catch.hpp"

#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/document/view.hpp>
#include <mongocxx/read_preference.hpp>

using namespace mongocxx;
using namespace bsoncxx;

TEST_CASE("Read Preference", "[read_preference]") {

    read_preference rp;
    auto tags = builder::stream::document{} << "blah" << "wow" << builder::stream::finalize;

    SECTION("Defaults to mode primary and empty tags") {
        REQUIRE(rp.mode() == read_preference::read_mode::k_primary);
        REQUIRE_FALSE(rp.tags());

        SECTION("Can have mode changed") {
            rp.mode(read_preference::read_mode::k_nearest);
            REQUIRE(rp.mode() == read_preference::read_mode::k_nearest);
        }

        SECTION("Can have tags changed") {
            rp.tags(tags);
            REQUIRE(rp.tags().value() == tags);
        }