#pragma once

#include "xtr\core\SelectableSet.h"
#include "xtr\doc\FileVersions.hpp"
#include "xtr\io\SerializationManager.hpp"

#include "ccl\semantic\RSForm.h"

std::vector<CString> GetFilesIn(const CString directory);
CString LocalPathToGlobal(CString local);

class MockArchive {
  std::unique_ptr<CFile> file{ nullptr };
  std::unique_ptr<CArchive> archive{ nullptr };

public:
  MockArchive() = default;
  ~MockArchive();

public:
  xtr::io::CArchiveAdapter GenerateAdapter() noexcept;
  bool LoadFile(CString path, bool toEdit = false);
  void CloseFile();
};

struct MockRSFormDoc : public xtr::io::MFCSerializable<xtr::TRSVersion> {
  xtr::TRSVersion version{ xtr::TRSVersion::old };
  std::unique_ptr<ccl::semantic::RSForm> schema{ std::make_unique<ccl::semantic::RSForm>() };
  SetOfEntities selection{};
  bool isClaimed{ false };

  MockRSFormDoc() = default;

  bool LoadFrom(CString path);
  bool SaveTo(CString path);

  JSON ExtractData() const override;
  bool LoadData(const JSON& object) override;
  bool LegacyLoad(xtr::io::CArchiveAdapter& archive) override;
};

struct MockRSModelDoc : public xtr::io::MFCSerializable<xtr::RSMVersion> {
  xtr::RSMVersion version{ xtr::RSMVersion::old };
  std::unique_ptr<ccl::semantic::RSModel> model{ std::make_unique<ccl::semantic::RSModel>() };
  SetOfEntities selection{};

  MockRSModelDoc() = default;

  bool LoadFrom(CString path);
  bool SaveTo(CString path);

  JSON ExtractData() const override;
  bool LoadData(const JSON& object) override;
  bool LegacyLoad(xtr::io::CArchiveAdapter& archive) override;
};

struct MockOSSDoc : public xtr::io::MFCSerializable<xtr::OSSVersion> {
  xtr::OSSVersion version{ xtr::OSSVersion::old };
  std::unique_ptr<ccl::oss::OSSchema> oss{ std::make_unique<ccl::oss::OSSchema>() };
  ccl::oss::PictID selection{ 0 };

  MockOSSDoc() = default;

  bool LoadFrom(CString path);
  bool SaveTo(CString path);

  JSON ExtractData() const override;
  bool LoadData(const JSON& object) override;
  bool LegacyLoad(xtr::io::CArchiveAdapter& archive) override;
};