tests/testthat/test-check_scenario_result_present.R

# initialise list
path <- system.file("testdata", "three3", package = "mm.reoptimise")
scenario <- create_scenario(path)
scenario_list <- list(scenario)

# make a new scenario
myscenario_profit <- set_scenario(scenario_list[[1]],
                                  period = "month",
                                  budget = 3.8e7,
                                  kpi1 = "Profit",
                                  kpi2 = "Profit",
                                  kpi3 = "Profit")


myscenario_profit <- run_optimization(
      scenario = myscenario_profit)

# add new scenario to the list
myname <- "my new net profit scenario"
scenario_list <- add_scenario(scenario_list, myscenario_profit, myname)

# test function
test_that("output is correct", {

      expect_equal(check_scenario_result_present(scenario_list) %>% length(), length(scenario_list))
      expect_equal(check_scenario_result_present(scenario_list), c(F ,T))

})
cath-parkinson/mm.reoptimise documentation built on May 12, 2022, 3:34 p.m.