use solverforge::prelude::*;
use solverforge::stream::ConstraintFactory;
#[problem_fact]
pub struct Employee {
#[planning_id]
pub id: i64,
pub name: String,
}
#[planning_entity]
pub struct Shift {
#[planning_id]
pub id: i64,
#[planning_variable]
pub employee: Option<i64>,
}
#[planning_solution]
pub struct Schedule {
#[problem_fact_collection]
pub employees: Vec<Employee>,
#[planning_entity_collection]
pub shifts: Vec<Shift>,
#[planning_score]
pub score: Option<HardSoftScore>,
}
#[test]
fn test_one_hard_returns_correct_score() {
let hard = HardSoftScore::one_hard();
assert_eq!(hard, HardSoftScore::of(1, 0));
}
#[test]
fn test_one_soft_returns_correct_score() {
let soft = HardSoftScore::one_soft();
assert_eq!(soft, HardSoftScore::of(0, 1));
}
#[test]
fn test_soft_score_one_soft() {
let soft = SoftScore::one_soft();
assert_eq!(soft, SoftScore::of(1));
}
#[test]
fn test_constraint_stream_accessors_compile() {
use ScheduleConstraintStreams;
use ShiftUnassignedFilter;
let factory = ConstraintFactory::<Schedule, HardSoftScore>::new();
let _shifts_stream = factory.shifts();
let factory3 = ConstraintFactory::<Schedule, HardSoftScore>::new();
let _unassigned_stream = factory3.shifts().unassigned();
let factory2 = ConstraintFactory::<Schedule, HardSoftScore>::new();
let _employees_stream = factory2.employees();
}
#[test]
fn test_penalize_hard_compiles_on_stream() {
use ScheduleConstraintStreams;
let factory = ConstraintFactory::<Schedule, HardSoftScore>::new();
let constraint = factory.shifts().penalize_hard().named("Test penalize hard");
let _ = constraint;
}
#[test]
fn test_penalize_soft_compiles_on_stream() {
use ScheduleConstraintStreams;
let factory = ConstraintFactory::<Schedule, HardSoftScore>::new();
let constraint = factory.shifts().penalize_soft().named("Test penalize soft");
let _ = constraint;
}
#[test]
fn test_named_alias_compiles() {
use ScheduleConstraintStreams;
let factory = ConstraintFactory::<Schedule, HardSoftScore>::new();
let constraint = factory.shifts().penalize_hard().named("Test named alias");
let _ = constraint;
}