1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
use super::*;
#[derive(Debug, Default, PartialEq, Eq, Clone)]
pub struct Venue {
pub(super) inner: InnerComponent,
}
impl Venue {
pub fn new() -> Self {
Default::default()
}
pub fn done(&mut self) -> Self {
Venue {
inner: self.inner.done(),
}
}
pub fn street_address(&mut self, address: &str) -> &mut Self {
self.add_property("STREET-ADDRESS", address)
}
pub fn get_street_address(&self) -> Option<&str> {
self.property_value("STREET-ADDRESS")
}
pub fn extended_address(&mut self, address: &str) -> &mut Self {
self.add_property("EXTENDED-ADDRESS", address)
}
pub fn get_extended_address(&self) -> Option<&str> {
self.property_value("EXTENDED-ADDRESS")
}
pub fn locality(&mut self, locality: &str) -> &mut Self {
self.add_property("LOCALITY", locality)
}
pub fn get_locality(&self) -> Option<&str> {
self.property_value("LOCALITY")
}
pub fn region(&mut self, region: &str) -> &mut Self {
self.add_property("REGION", region)
}
pub fn get_region(&self) -> Option<&str> {
self.property_value("REGION")
}
pub fn country(&mut self, country: &str) -> &mut Self {
self.add_property("COUNTRY", country)
}
pub fn get_country(&self) -> Option<&str> {
self.property_value("COUNTRY")
}
pub fn postal_code(&mut self, postal_code: &str) -> &mut Self {
self.add_property("POSTAL-CODE", postal_code)
}
pub fn get_postal_code(&self) -> Option<&str> {
self.property_value("POSTAL-CODE")
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn get_properties_unset() {
let venue = Venue::new();
assert_eq!(venue.get_street_address(), None);
assert_eq!(venue.get_extended_address(), None);
assert_eq!(venue.get_locality(), None);
assert_eq!(venue.get_region(), None);
assert_eq!(venue.get_country(), None);
assert_eq!(venue.get_postal_code(), None);
}
#[test]
fn get_properties_set() {
let venue = Venue::new()
.street_address("street address")
.extended_address("extended address")
.locality("locality")
.region("region")
.country("country")
.postal_code("postal code")
.done();
assert_eq!(venue.get_street_address(), Some("street address"));
assert_eq!(venue.get_extended_address(), Some("extended address"));
assert_eq!(venue.get_locality(), Some("locality"));
assert_eq!(venue.get_region(), Some("region"));
assert_eq!(venue.get_country(), Some("country"));
assert_eq!(venue.get_postal_code(), Some("postal code"));
}
}