# WARNING - Generated by {fusen} from dev/flat_economic.Rmd: do not edit by hand # nolint: line_length_linter. test_that("annual_cost works", { scenario_apprentissage <- create_scenario( system.file("input_1culture_2pop.xlsx", package = "ambre") ) result <- annual_cost(scenario = scenario_apprentissage, price_per_m3 = 0.1, membership_fee = 200, grant = 0.5, initialSituation = TRUE) expect_true(all(c("plot_annual_cost", "allocation_key") %in% names(result))) expect_equal(object = result$allocation_key, expected = structure(list(grant = c(0.5, 0.5), CropName = c("Tomato", "Corn seed" ), allocation = c(0.1111, 0.3889)), row.names = 1:2, class = "data.frame")) crop <- scenario_apprentissage$CropName allocation_custom <- data.frame(CropName = crop, allocation = c(0.5, 0.5)) result <- annual_cost(scenario = scenario_apprentissage, price_per_m3 = 0.1, membership_fee = 200, grant = 0, initialSituation = TRUE, allocation_key = allocation_custom) expect_equal(object = result$allocation_key, expected = structure(list(grant = c(0, 0), CropName = c("Tomato", "Corn seed" ), allocation = c(0.5, 0.5)), row.names = 1:2, class = "data.frame")) })