summaryrefslogtreecommitdiff
path: root/src/lib.rs
blob: 0eb08b7d5ebe3fcef5138841ba7f3001c441fdeb (plain) (blame)
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
use std::collections::HashSet;

// As an artist, I can upload artwork and attach it to a product
// As an artist, I can enter detailed information about a product
// As an artist, I can store a product for later recall by me or connoisseurs.
// As a connoisseur, I can search the gallery for artwork matching given keywords and see products
// containing that artwork
// As a connoisseur, I can select one or many products and submit them in a job to an artist

// Sellable artwork
struct Product {
    artwork: Artwork,
    cents: u64,
    quantity: u64,
    featured: bool,
}

impl Product {
    fn dollars(&self) -> f64 {
        self.cents as f64 / 100.0
    }
}

struct Artwork {
    name: String,
    description: String,
    category: Vec<String>,
    tags: HashSet<String>,
}

struct Customer {}

struct Artist {}

struct Search {}

trait Gallery {
    fn store(artwork: Artwork) -> Result<(), ()>;
}

struct MockGallery {}

impl Gallery for MockGallery {
    fn store(_artwork: Artwork) -> Result<(), ()> {
        Ok(())
    }
}

struct Job {}

fn add_two(a: usize, b: usize) -> usize {
    a + b
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn add() {
        assert_eq!(4, add_two(2, 2));
    }

    #[test]
    fn dollars() {
        let product = Product {
            artwork: Artwork {},
            cents: 1000,
        };
        assert_eq!(10.00, product.dollars());
        let product = Product {
            artwork: Artwork {},
            cents: 1234,
        };
        assert_eq!(12.34, product.dollars());
    }
}