Skip to content

Commit

Permalink
add mock sync provider and test
Browse files Browse the repository at this point in the history
  • Loading branch information
himaren committed May 8, 2024
1 parent 460b7c0 commit 2e76b75
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/address_book_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@

#include "address_book.hpp"

class mock_synchronization_provider : public synchronization_provider {
std::vector<std::string> entries;

public:
std::vector<std::string> synchronize(std::vector<std::string> serialized_entries) override {
entries = merge_entries(entries, serialized_entries);
return entries;
}



};

TEST_CASE("test address_book::syncronize") {
address_book ab;
mock_synchronization_provider provider = mock_synchronization_provider();

ab.add_entry("Jane Doe");
ab.synchronize(provider);
ab.remove_entry("Jane Doe");

ab.synchronize(provider);
CHECK(ab.has_entry("Jane Doe"));
}

TEST_CASE("entries can be added and removed") {
address_book ab;
CHECK_FALSE(ab.has_entry("Jane Doe"));
Expand Down

0 comments on commit 2e76b75

Please sign in to comment.