# agridatasets - A Comprehensive Collection of Agricultural and Agronomic Datasets
# Version 0.1.1
# Copyright (C) 2026 Renzo Caceres Rossi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

#  ladybird_fungus

library(testthat)

# Test 1: Check that the object is a tibble/data.frame and has 8 columns
test_that("ladybird_fungus is a tibble data.frame with 8 columns", {
  expect_s3_class(ladybird_fungus, "tbl_df")
  expect_s3_class(ladybird_fungus, "tbl")
  expect_s3_class(ladybird_fungus, "data.frame")
  expect_equal(ncol(ladybird_fungus), 8)
  expect_equal(length(ladybird_fungus), 8)
})

# Test 2: Check the number of rows
test_that("ladybird_fungus has 72 rows", {
  expect_equal(nrow(ladybird_fungus), 72)
})

# Test 3: Validate column names
test_that("ladybird_fungus has correct column names", {
  expect_named(
    ladybird_fungus,
    c("ID", "Run", "DPlant", "Host", "Ladybird", "Cadaver", "Live", "Infected")
  )
})

# Test 4: Check data types
test_that("ladybird_fungus has correct data types", {
  expect_s3_class(ladybird_fungus$ID, "factor")
  expect_equal(nlevels(ladybird_fungus$ID), 72)
  expect_s3_class(ladybird_fungus$Run, "factor")
  expect_equal(nlevels(ladybird_fungus$Run), 2)
  expect_s3_class(ladybird_fungus$DPlant, "factor")
  expect_equal(nlevels(ladybird_fungus$DPlant), 36)
  expect_s3_class(ladybird_fungus$Host, "factor")
  expect_equal(nlevels(ladybird_fungus$Host), 2)
  expect_s3_class(ladybird_fungus$Ladybird, "factor")
  expect_equal(nlevels(ladybird_fungus$Ladybird), 2)
  expect_type(ladybird_fungus$Cadaver, "integer")
  expect_type(ladybird_fungus$Live, "integer")
  expect_type(ladybird_fungus$Infected, "integer")
})
