blob: 7adb6fc022a6a1b2b37d0e6ed3f50e08cf59a853 [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PERIDOT_LIB_TESTING_MOCK_BASE_H_
#define PERIDOT_LIB_TESTING_MOCK_BASE_H_
#include <map>
#include <string>
namespace modular {
namespace testing {
// Helper class for unit testing that provides a collection to track the number
// of times each function is called, then provides functions to validate those
// calls.
class MockBase {
public:
MockBase();
virtual ~MockBase();
// Validates that the given function was called once and removes that
// information from the call history
void ExpectCalledOnce(const std::string& func);
// Removes the entire history of functions called
void ClearCalls();
// Validates that the call history is empty
void ExpectNoOtherCalls();
protected:
std::map<std::string, unsigned int> counts;
};
} // namespace testing
} // namespace modular
#endif // PERIDOT_LIB_TESTING_MOCK_BASE_H_