1
exercism fetch csharp book-store

BookStoreTest.cs

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
// This file was auto-generated based on version 1.1.0 of the canonical data.

using Xunit;

public class BookStoreTest
{
    [Fact]
    public void Only_a_single_book()
    {
        var basket = new[] { 1 };
        Assert.Equal(8, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Two_of_the_same_book()
    {
        var basket = new[] { 2, 2 };
        Assert.Equal(16, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Empty_basket()
    {
        var basket = new int[0];
        Assert.Equal(0, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Two_different_books()
    {
        var basket = new[] { 1, 2 };
        Assert.Equal(15.2, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Three_different_books()
    {
        var basket = new[] { 1, 2, 3 };
        Assert.Equal(21.6, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Four_different_books()
    {
        var basket = new[] { 1, 2, 3, 4 };
        Assert.Equal(25.6, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Five_different_books()
    {
        var basket = new[] { 1, 2, 3, 4, 5 };
        Assert.Equal(30, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Two_groups_of_four_is_cheaper_than_group_of_five_plus_group_of_three()
    {
        var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 5 };
        Assert.Equal(51.2, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Group_of_four_plus_group_of_two_is_cheaper_than_two_groups_of_three()
    {
        var basket = new[] { 1, 1, 2, 2, 3, 4 };
        Assert.Equal(40.8, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Two_each_of_first_4_books_and_1_copy_each_of_rest()
    {
        var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5 };
        Assert.Equal(55.6, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Two_copies_of_each_book()
    {
        var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
        Assert.Equal(60, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Three_copies_of_first_book_and_2_each_of_remaining()
    {
        var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1 };
        Assert.Equal(68, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Three_each_of_first_2_books_and_2_each_of_remaining_books()
    {
        var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2 };
        Assert.Equal(75.2, BookStore.Total(basket));
    }

    [Fact(Skip = "Remove to run test")]
    public void Four_groups_of_four_are_cheaper_than_two_groups_each_of_five_and_three()
    {
        var basket = new[] { 1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5 };
        Assert.Equal(102.4, BookStore.Total(basket));
    }
}