diff --git a/R/vector_control.R b/R/vector_control.R index 0537d746..3272b7f8 100644 --- a/R/vector_control.R +++ b/R/vector_control.R @@ -189,7 +189,7 @@ spraying_decay <- function(t, theta, gamma) { net_usage_renderer <- function(net_time, renderer) { function(t) { renderer$render( - 'net_usage', + 'n_use_net', net_time$get_index_of(-1)$not(TRUE)$size(), t ) diff --git a/tests/testthat/test-vector-control.R b/tests/testthat/test-vector-control.R index 8af13a2e..47a89d9d 100644 --- a/tests/testthat/test-vector-control.R +++ b/tests/testthat/test-vector-control.R @@ -314,3 +314,20 @@ test_that('prob_bitten correctly combines spraying and net probabilities', { tolerance=1e-4 ) }) + +test_that('usage renderer outputs correct values', { + timestep <- 150 + + all <- individual::IntegerVariable$new(c(100, 50, 5, 50)) + half <- individual::IntegerVariable$new(c(100, 50, -1, -1)) + none <- individual::IntegerVariable$new(rep(-1, 4)) + + renderer <- list(render = mockery::mock()) + net_usage_renderer(all, renderer)(timestep) + net_usage_renderer(half, renderer)(timestep) + net_usage_renderer(none, renderer)(timestep) + + mockery::expect_args(renderer$render, 1, 'n_use_net', 4, timestep) + mockery::expect_args(renderer$render, 2, 'n_use_net', 2, timestep) + mockery::expect_args(renderer$render, 3, 'n_use_net', 0, timestep) +})