reactive_graph_std_arithmetic/
providers.rs1use reactive_graph_plugin_api::prelude::providers::*;
2
3#[derive(TypeProvider, Component)]
4#[type_provider(tys = "Components", path = "types/components")]
5pub struct ArithmeticComponentsProvider {}
6
7#[derive(TypeProvider, Component)]
8#[type_provider(tys = "EntityTypes", path = "types/entities")]
9pub struct ArithmeticEntityTypesProvider {}
10
11#[cfg(test)]
12mod tests {
13 use reactive_graph_graph::prelude::*;
14
15 use reactive_graph_std_arithmetic_model::NAMESPACE_ARITHMETIC;
16 use reactive_graph_std_arithmetic_model::NAMESPACE_ARITHMETIC_F64;
17 use reactive_graph_std_arithmetic_model::NAMESPACE_ARITHMETIC_I64;
18 use reactive_graph_std_arithmetic_model::NAMESPACE_ARITHMETIC_U64;
19
20 use super::*;
21
22 #[test]
23 fn components_should_exist() {
24 let expected_components = ComponentTypeIds::with_namespace(NAMESPACE_ARITHMETIC)
25 .ty("arithmetic_gate")
26 .ty("arithmetic_operation");
27 let component_provider = ArithmeticComponentsProvider {};
28 assert!(
29 component_provider
30 .get_types()
31 .iter()
32 .all(|component| expected_components.contains(component.key()))
33 );
34 }
35
36 #[test]
37 fn entity_types_should_exist() {
38 let entity_type_provider = ArithmeticEntityTypesProvider {};
39 let expected_entity_types_f64 = EntityTypeIds::with_namespace(NAMESPACE_ARITHMETIC_F64)
40 .ty("add")
41 .ty("decrement")
42 .ty("div")
43 .ty("increment")
44 .ty("max")
45 .ty("min")
46 .ty("mod")
47 .ty("mul")
48 .ty("sub");
49 let expected_entity_types_i64 = EntityTypeIds::with_namespace(NAMESPACE_ARITHMETIC_I64)
50 .ty("add")
51 .ty("decrement")
52 .ty("div")
53 .ty("increment")
54 .ty("max")
55 .ty("min")
56 .ty("mod")
57 .ty("mul")
58 .ty("sub");
59 let expected_entity_types_u64 = EntityTypeIds::with_namespace(NAMESPACE_ARITHMETIC_U64)
60 .ty("add")
61 .ty("decrement")
62 .ty("div")
63 .ty("increment")
64 .ty("max")
65 .ty("min")
66 .ty("mod")
67 .ty("mul")
68 .ty("sub")
69 .ty("counter");
70 assert!(entity_type_provider.get_types().iter().all(|entity_type| {
71 expected_entity_types_f64.contains(entity_type.key())
72 || expected_entity_types_i64.contains(entity_type.key())
73 || expected_entity_types_u64.contains(entity_type.key())
74 }));
75 }
76}