// Copyright 2024 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, 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.
#pragma once

#include "modules/board/board.rpc.pb.h"

namespace sense {

/// Implements and extends the ``Board`` interface to facilitate unit testing.
class BoardFake : public Board {
 public:
  board_RebootType_Enum last_reboot_type() const { return last_reboot_type_; }
  void set_internal_temperature(float internal_temperature) {
    internal_temperature_ = internal_temperature;
  }

  /// @copydoc ``Board::ReadInternalTemperature``.
  float ReadInternalTemperature() override { return internal_temperature_; }

  /// @copydoc ``Board::Reboot``.
  pw::Status Reboot(board_RebootType_Enum reboot_type) override {
    last_reboot_type_ = reboot_type;
    return pw::OkStatus();
  }

  uint64_t UniqueFlashId() const override { return kFakeFlashId; }

 private:
  static constexpr uint64_t kFakeFlashId = 0x0000aabbccddeeff;
  float internal_temperature_ = 20.0f;
  board_RebootType_Enum last_reboot_type_ = board_RebootType_Enum_UNKNOWN;
};

}  // namespace sense
