test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_only_fluo - default", {
  test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv")
  data <- read_dual_pam_single_channel_fluo_data(test_data_file)

  par <- data$par
  expect_equal(par[1], 0)
  expect_equal(par[2], 39)
  expect_equal(par[3], 49)
  expect_equal(par[4], 62)
  expect_equal(par[5], 113)
  expect_equal(par[6], 185)
  expect_equal(par[7], 241)
  expect_equal(par[8], 397)
  expect_equal(par[9], 614)
  expect_equal(par[10], 946)
  expect_equal(par[11], 1453)

  yield_1 <- data$yield_1
  expect_equal(yield_1[1], NA_real_)
  expect_equal(yield_1[2], NA_real_)
  expect_equal(yield_1[3], NA_real_)
  expect_equal(yield_1[4], NA_real_)
  expect_equal(yield_1[5], NA_real_)
  expect_equal(yield_1[6], NA_real_)
  expect_equal(yield_1[7], NA_real_)
  expect_equal(yield_1[8], NA_real_)
  expect_equal(yield_1[9], NA_real_)
  expect_equal(yield_1[10], NA_real_)
  expect_equal(yield_1[11], NA_real_)

  yield_2 <- data$yield_2
  expect_equal(yield_2[1], 0.7670)
  expect_equal(yield_2[2], 0.3410)
  expect_equal(yield_2[3], 0.3140)
  expect_equal(yield_2[4], 0.2860)
  expect_equal(yield_2[5], 0.2010)
  expect_equal(yield_2[6], 0.139)
  expect_equal(yield_2[7], 0.112)
  expect_equal(yield_2[8], 0.0720)
  expect_equal(yield_2[9], 0.0480)
  expect_equal(yield_2[10], 0.0320)
  expect_equal(yield_2[11], 0.02)

  etr_1 <- data$etr_1
  expect_equal(etr_1[1], NA_real_)
  expect_equal(etr_1[2], NA_real_)
  expect_equal(etr_1[3], NA_real_)
  expect_equal(etr_1[4], NA_real_)
  expect_equal(etr_1[5], NA_real_)
  expect_equal(etr_1[6], NA_real_)
  expect_equal(etr_1[7], NA_real_)
  expect_equal(etr_1[8], NA_real_)
  expect_equal(etr_1[9], NA_real_)
  expect_equal(etr_1[10], NA_real_)
  expect_equal(etr_1[11], NA_real_)

  etr_2 <- data$etr_2
  expect_equal(etr_2[1], 0)
  expect_equal(etr_2[2], 5.585580)
  expect_equal(etr_2[3], 6.462120)
  expect_equal(etr_2[4], 7.44744)
  expect_equal(etr_2[5], 9.53946)
  expect_equal(etr_2[6], 10.80030)
  expect_equal(etr_2[7], 11.33664)
  expect_equal(etr_2[8], 12.005280)
  expect_equal(etr_2[9], 12.37824)
  expect_equal(etr_2[10], 12.71424)
  expect_equal(etr_2[11], 12.2052)
})

test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_only_fluo - etr_factor 0.5", {
  test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv")
  data <- read_dual_pam_single_channel_fluo_data(test_data_file, etr_factor = 0.5)

  par <- data$par
  expect_equal(par[1], 0)
  expect_equal(par[2], 39)
  expect_equal(par[3], 49)
  expect_equal(par[4], 62)
  expect_equal(par[5], 113)
  expect_equal(par[6], 185)
  expect_equal(par[7], 241)
  expect_equal(par[8], 397)
  expect_equal(par[9], 614)
  expect_equal(par[10], 946)
  expect_equal(par[11], 1453)

  yield_1 <- data$yield_1
  expect_equal(yield_1[1], NA_real_)
  expect_equal(yield_1[2], NA_real_)
  expect_equal(yield_1[3], NA_real_)
  expect_equal(yield_1[4], NA_real_)
  expect_equal(yield_1[5], NA_real_)
  expect_equal(yield_1[6], NA_real_)
  expect_equal(yield_1[7], NA_real_)
  expect_equal(yield_1[8], NA_real_)
  expect_equal(yield_1[9], NA_real_)
  expect_equal(yield_1[10], NA_real_)
  expect_equal(yield_1[11], NA_real_)

  yield_2 <- data$yield_2
  expect_equal(yield_2[1], 0.7670)
  expect_equal(yield_2[2], 0.3410)
  expect_equal(yield_2[3], 0.3140)
  expect_equal(yield_2[4], 0.2860)
  expect_equal(yield_2[5], 0.2010)
  expect_equal(yield_2[6], 0.139)
  expect_equal(yield_2[7], 0.112)
  expect_equal(yield_2[8], 0.0720)
  expect_equal(yield_2[9], 0.0480)
  expect_equal(yield_2[10], 0.0320)
  expect_equal(yield_2[11], 0.02)

  etr_1 <- data$etr_1
  expect_equal(etr_1[1], NA_real_)
  expect_equal(etr_1[2], NA_real_)
  expect_equal(etr_1[3], NA_real_)
  expect_equal(etr_1[4], NA_real_)
  expect_equal(etr_1[5], NA_real_)
  expect_equal(etr_1[6], NA_real_)
  expect_equal(etr_1[7], NA_real_)
  expect_equal(etr_1[8], NA_real_)
  expect_equal(etr_1[9], NA_real_)
  expect_equal(etr_1[10], NA_real_)
  expect_equal(etr_1[11], NA_real_)

  etr_2 <- data$etr_2
  expect_equal(etr_2[1], 0)
  expect_equal(etr_2[2], 3.32475)
  expect_equal(etr_2[3], 3.84650)
  expect_equal(etr_2[4], 4.433)
  expect_equal(etr_2[5], 5.67825)
  expect_equal(etr_2[6], 6.42875)
  expect_equal(etr_2[7], 6.748)
  expect_equal(etr_2[8], 7.146)
  expect_equal(etr_2[9], 7.368)
  expect_equal(etr_2[10], 7.568)
  expect_equal(etr_2[11], 7.265)
})

test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_only_fluo - fraction_photosystem > 1", {
  test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv")
  expect_error(read_dual_pam_single_channel_fluo_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2))
})

test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_only_fluo - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", {
  test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv")
  data <- read_dual_pam_single_channel_fluo_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8)

  par <- data$par
  expect_equal(par[1], 0)
  expect_equal(par[2], 39)
  expect_equal(par[3], 49)
  expect_equal(par[4], 62)
  expect_equal(par[5], 113)
  expect_equal(par[6], 185)
  expect_equal(par[7], 241)
  expect_equal(par[8], 397)
  expect_equal(par[9], 614)
  expect_equal(par[10], 946)
  expect_equal(par[11], 1453)

  yield_1 <- data$yield_1
  expect_equal(yield_1[1], NA_real_)
  expect_equal(yield_1[2], NA_real_)
  expect_equal(yield_1[3], NA_real_)
  expect_equal(yield_1[4], NA_real_)
  expect_equal(yield_1[5], NA_real_)
  expect_equal(yield_1[6], NA_real_)
  expect_equal(yield_1[7], NA_real_)
  expect_equal(yield_1[8], NA_real_)
  expect_equal(yield_1[9], NA_real_)
  expect_equal(yield_1[10], NA_real_)
  expect_equal(yield_1[11], NA_real_)

  yield_2 <- data$yield_2
  expect_equal(yield_2[1], 0.7670)
  expect_equal(yield_2[2], 0.3410)
  expect_equal(yield_2[3], 0.3140)
  expect_equal(yield_2[4], 0.2860)
  expect_equal(yield_2[5], 0.2010)
  expect_equal(yield_2[6], 0.139)
  expect_equal(yield_2[7], 0.112)
  expect_equal(yield_2[8], 0.0720)
  expect_equal(yield_2[9], 0.0480)
  expect_equal(yield_2[10], 0.0320)
  expect_equal(yield_2[11], 0.02)

  etr_1 <- data$etr_1
  expect_equal(etr_1[1], NA_real_)
  expect_equal(etr_1[2], NA_real_)
  expect_equal(etr_1[3], NA_real_)
  expect_equal(etr_1[4], NA_real_)
  expect_equal(etr_1[5], NA_real_)
  expect_equal(etr_1[6], NA_real_)
  expect_equal(etr_1[7], NA_real_)
  expect_equal(etr_1[8], NA_real_)
  expect_equal(etr_1[9], NA_real_)
  expect_equal(etr_1[10], NA_real_)
  expect_equal(etr_1[11], NA_real_)

  etr_2 <- data$etr_2
  expect_equal(etr_2[1], 0.0)
  expect_equal(etr_2[2], 8.936928)
  expect_equal(etr_2[3], 10.3393920)
  expect_equal(etr_2[4], 11.915904)
  expect_equal(etr_2[5], 15.2631360)
  expect_equal(etr_2[6], 17.28048)
  expect_equal(etr_2[7], 18.1386240)
  expect_equal(etr_2[8], 19.208448)
  expect_equal(etr_2[9], 19.805184)
  expect_equal(etr_2[10], 20.3427840)
  expect_equal(etr_2[11], 19.52832)
})
