Skip to content

Commit 9e6aeb3

Browse files
committed
Change ksu-cis#2
1 parent b2a00a0 commit 9e6aeb3

File tree

8 files changed

+170
-7
lines changed

8 files changed

+170
-7
lines changed

Data/Drinks/CandlehearthCoffee.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public override string ToString()
124124
{
125125
StringBuilder sb = new StringBuilder();
126126
sb.Append(Size);
127+
if (Decaf) sb.Append(" Decaf");
127128
sb.Append(" Candlehearth Coffee");
128129
return sb.ToString();
129130
}

Data/Drinks/SailorSoda.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class SailorSoda
1313
/// <summary>
1414
/// sets the private fields to their default values
1515
/// </summary>
16-
private bool ice = false;
16+
private bool ice = true;
1717
private Size size = Size.Small;
1818
private SodaFlavor flavor = SodaFlavor.Cherry;
1919

@@ -93,9 +93,9 @@ public List<string> SpecialInstructions {
9393
get
9494
{
9595
List<string> list = new List<string>();
96-
if (Ice)
96+
if (!Ice)
9797
{
98-
list.Add("Add ice");
98+
list.Add("Hold ice");
9999
}
100100

101101
return list;

DataTests/DataTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77

DataTests/UnitTests/DrinkTests/AretinoAppleJuiceTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
using Xunit;
77

8+
using System.Collections.Generic;
89
using BleakwindBuffet.Data;
910
using BleakwindBuffet.Data.Enums;
1011
using BleakwindBuffet.Data.Drinks;
@@ -76,9 +77,10 @@ public void ShouldHaveCorrectSpecialInstructions(bool includeIce)
7677
{
7778
AretinoAppleJuice apple = new AretinoAppleJuice();
7879
apple.Ice = includeIce;
80+
List<string> list = apple.SpecialInstructions;
7981

80-
if (includeIce) Assert.Equal("Add ice", apple.SpecialInstructions[0]);
81-
else Assert.Equal("", apple.SpecialInstructions[0]);
82+
if (includeIce) Assert.Equal("Add ice", list[0]);
83+
else Assert.Empty(list);
8284
}
8385

8486
[Theory]

DataTests/UnitTests/DrinkTests/CandlehearthCoffeeTests.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
using BleakwindBuffet.Data;
99
using BleakwindBuffet.Data.Enums;
10+
using BleakwindBuffet.Data.Drinks;
1011

1112
namespace BleakwindBuffet.DataTests.UnitTests.DrinkTests
1213
{
@@ -15,41 +16,63 @@ public class CandlehearthCoffeeTests
1516
[Fact]
1617
public void ShouldNotIncludeIceByDefault()
1718
{
19+
CandlehearthCoffee coffee = new CandlehearthCoffee();
20+
Assert.False(coffee.Ice);
1821
}
1922

2023
[Fact]
2124
public void ShouldNotBeDecafByDefault()
2225
{
26+
CandlehearthCoffee coffee = new CandlehearthCoffee();
27+
Assert.False(coffee.Decaf);
2328
}
2429

2530
[Fact]
2631
public void ShouldNotHaveRoomForCreamByDefault()
2732
{
33+
CandlehearthCoffee coffee = new CandlehearthCoffee();
34+
Assert.False(coffee.RoomForCream);
2835
}
2936

3037
[Fact]
3138
public void ShouldBeSmallByDefault()
3239
{
40+
CandlehearthCoffee coffee = new CandlehearthCoffee();
41+
Assert.Equal(Size.Small, coffee.Size);
3342
}
3443

3544
[Fact]
3645
public void ShouldBeAbleToSetIce()
3746
{
47+
CandlehearthCoffee coffee = new CandlehearthCoffee();
48+
coffee.Ice = true;
49+
Assert.True(coffee.Ice);
3850
}
3951

4052
[Fact]
4153
public void ShouldBeAbleToSetDecaf()
4254
{
55+
CandlehearthCoffee coffee = new CandlehearthCoffee();
56+
coffee.Decaf = true;
57+
Assert.True(coffee.Decaf);
4358
}
4459

4560
[Fact]
4661
public void ShouldBeAbleToSetRoomForCream()
4762
{
63+
CandlehearthCoffee coffee = new CandlehearthCoffee();
64+
coffee.RoomForCream = true;
65+
Assert.True(coffee.RoomForCream);
4866
}
4967

5068
[Fact]
5169
public void ShouldBeAbleToSetSize()
5270
{
71+
CandlehearthCoffee coffee = new CandlehearthCoffee();
72+
coffee.Size = Size.Medium;
73+
Assert.Equal(Size.Medium, coffee.Size);
74+
coffee.Size = Size.Large;
75+
Assert.Equal(Size.Large, coffee.Size);
5376
}
5477

5578
[Theory]
@@ -58,6 +81,9 @@ public void ShouldBeAbleToSetSize()
5881
[InlineData(Size.Large, 1.75)]
5982
public void ShouldHaveCorrectPriceForSize(Size size, double price)
6083
{
84+
CandlehearthCoffee coffee = new CandlehearthCoffee();
85+
coffee.Size = size;
86+
Assert.True(price == coffee.Price);
6187
}
6288

6389
[Theory]
@@ -66,6 +92,9 @@ public void ShouldHaveCorrectPriceForSize(Size size, double price)
6692
[InlineData(Size.Large, 20)]
6793
public void ShouldHaveCorrectCaloriesForSize(Size size, uint cal)
6894
{
95+
CandlehearthCoffee coffee = new CandlehearthCoffee();
96+
coffee.Size = size;
97+
Assert.True(cal == coffee.Calories);
6998
}
7099

71100
[Theory]
@@ -75,6 +104,27 @@ public void ShouldHaveCorrectCaloriesForSize(Size size, uint cal)
75104
[InlineData(false, false)]
76105
public void ShouldHaveCorrectSpecialInstructions(bool includeIce, bool includeCream)
77106
{
107+
CandlehearthCoffee coffee = new CandlehearthCoffee();
108+
coffee.Ice = includeIce;
109+
coffee.RoomForCream = includeCream;
110+
111+
if (includeIce && includeCream)
112+
{
113+
Assert.Equal("Add ice", coffee.SpecialInstructions[0]);
114+
Assert.Equal("Add cream", coffee.SpecialInstructions[1]);
115+
}
116+
else if (includeIce && !includeCream)
117+
{
118+
Assert.Equal("Add ice", coffee.SpecialInstructions[0]);
119+
}
120+
else if (!includeIce && includeCream)
121+
{
122+
Assert.Equal("Add cream", coffee.SpecialInstructions[0]);
123+
}
124+
else
125+
{
126+
Assert.Empty(coffee.SpecialInstructions);
127+
}
78128
}
79129

80130
[Theory]
@@ -86,6 +136,10 @@ public void ShouldHaveCorrectSpecialInstructions(bool includeIce, bool includeCr
86136
[InlineData(false, Size.Large, "Large Candlehearth Coffee")]
87137
public void ShouldReturnCorrectToStringBasedOnSize(bool decaf, Size size, string name)
88138
{
139+
CandlehearthCoffee coffee = new CandlehearthCoffee();
140+
coffee.Decaf = decaf;
141+
coffee.Size = size;
142+
Assert.Equal(name, coffee.ToString());
89143
}
90144
}
91145
}

DataTests/UnitTests/DrinkTests/MarkarthMilkTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
using BleakwindBuffet.Data;
99
using BleakwindBuffet.Data.Enums;
10+
using BleakwindBuffet.Data.Drinks;
1011

1112
namespace BleakwindBuffet.DataTests.UnitTests.DrinkTests
1213
{
@@ -15,21 +16,33 @@ public class MarkarthMilkTests
1516
[Fact]
1617
public void ShouldNotIncludeIceByDefault()
1718
{
19+
MarkarthMilk milk = new MarkarthMilk();
20+
Assert.False(milk.Ice);
1821
}
1922

2023
[Fact]
2124
public void ShouldBySmallByDefault()
2225
{
26+
MarkarthMilk milk = new MarkarthMilk();
27+
Assert.Equal(Size.Small, milk.Size);
2328
}
2429

2530
[Fact]
2631
public void ShouldByAbleToSetIce()
2732
{
33+
MarkarthMilk milk = new MarkarthMilk();
34+
milk.Ice = true;
35+
Assert.True(milk.Ice);
2836
}
2937

3038
[Fact]
3139
public void ShouldBeAbleToSetSize()
3240
{
41+
MarkarthMilk milk = new MarkarthMilk();
42+
milk.Size = Size.Medium;
43+
Assert.Equal(Size.Medium, milk.Size);
44+
milk.Size = Size.Large;
45+
Assert.Equal(Size.Large, milk.Size);
3346
}
3447

3548
[Theory]
@@ -38,6 +51,9 @@ public void ShouldBeAbleToSetSize()
3851
[InlineData(Size.Large, 1.22)]
3952
public void ShouldHaveCorrectPriceForSize(Size size, double price)
4053
{
54+
MarkarthMilk milk = new MarkarthMilk();
55+
milk.Size = size;
56+
Assert.True(milk.Price == price);
4157
}
4258

4359
[Theory]
@@ -46,13 +62,21 @@ public void ShouldHaveCorrectPriceForSize(Size size, double price)
4662
[InlineData(Size.Large, 93)]
4763
public void ShouldHaveCorrectCaloriesForSize(Size size, uint cal)
4864
{
65+
MarkarthMilk milk = new MarkarthMilk();
66+
milk.Size = size;
67+
Assert.True(milk.Calories == cal);
4968
}
5069

5170
[Theory]
5271
[InlineData(true)]
5372
[InlineData(false)]
5473
public void ShouldHaveCorrectSpecialInstructions(bool includeIce)
5574
{
75+
MarkarthMilk milk = new MarkarthMilk();
76+
milk.Ice = includeIce;
77+
78+
if (includeIce) Assert.Equal("Add ice", milk.SpecialInstructions[0]);
79+
else Assert.Empty(milk.SpecialInstructions);
5680
}
5781

5882
[Theory]
@@ -61,6 +85,9 @@ public void ShouldHaveCorrectSpecialInstructions(bool includeIce)
6185
[InlineData(Size.Large, "Large Markarth Milk")]
6286
public void ShouldReturnCorrectToStringBasedOnSize(Size size, string name)
6387
{
88+
MarkarthMilk milk = new MarkarthMilk();
89+
milk.Size = size;
90+
Assert.Equal(name, milk.ToString());
6491
}
6592
}
6693
}

DataTests/UnitTests/DrinkTests/SailorSodaTests.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
using BleakwindBuffet.Data;
1111
using BleakwindBuffet.Data.Enums;
12+
using BleakwindBuffet.Data.Drinks;
1213

1314
namespace BleakwindBuffet.DataTests.UnitTests.DrinkTests
1415
{
@@ -17,31 +18,56 @@ public class SailorSodaTests
1718
[Fact]
1819
public void ShouldIncludeIceByDefault()
1920
{
21+
SailorSoda soda = new SailorSoda();
22+
Assert.True(soda.Ice);
2023
}
2124

2225
[Fact]
2326
public void ShouldBeSmallByDefault()
2427
{
28+
SailorSoda soda = new SailorSoda();
29+
Assert.Equal(Size.Small, soda.Size);
2530
}
2631

2732
[Fact]
2833
public void FlavorShouldBeCherryByDefault()
2934
{
35+
SailorSoda soda = new SailorSoda();
36+
Assert.Equal(SodaFlavor.Cherry, soda.Flavor);
3037
}
3138

3239
[Fact]
3340
public void ShouldBeAbleToSetIce()
3441
{
42+
SailorSoda soda = new SailorSoda();
43+
soda.Ice = false;
44+
Assert.False(soda.Ice);
3545
}
3646

3747
[Fact]
3848
public void ShouldBeAbleToSetSize()
3949
{
50+
SailorSoda soda = new SailorSoda();
51+
soda.Size = Size.Medium;
52+
Assert.Equal(Size.Medium, soda.Size);
53+
soda.Size = Size.Large;
54+
Assert.Equal(Size.Large, soda.Size);
4055
}
4156

4257
[Fact]
4358
public void ShouldBeAbleToSetFlavor()
4459
{
60+
SailorSoda soda = new SailorSoda();
61+
soda.Flavor = SodaFlavor.Blackberry;
62+
Assert.Equal(SodaFlavor.Blackberry, soda.Flavor);
63+
soda.Flavor = SodaFlavor.Grapefruit;
64+
Assert.Equal(SodaFlavor.Grapefruit, soda.Flavor);
65+
soda.Flavor = SodaFlavor.Lemon;
66+
Assert.Equal(SodaFlavor.Lemon, soda.Flavor);
67+
soda.Flavor = SodaFlavor.Peach;
68+
Assert.Equal(SodaFlavor.Peach, soda.Flavor);
69+
soda.Flavor = SodaFlavor.Watermelon;
70+
Assert.Equal(SodaFlavor.Watermelon, soda.Flavor);
4571
}
4672

4773
[Theory]
@@ -50,6 +76,9 @@ public void ShouldBeAbleToSetFlavor()
5076
[InlineData(Size.Large, 2.07)]
5177
public void ShouldHaveCorrectPriceForSize(Size size, double price)
5278
{
79+
SailorSoda soda = new SailorSoda();
80+
soda.Size = size;
81+
Assert.True(soda.Price == price);
5382
}
5483

5584
[Theory]
@@ -58,13 +87,21 @@ public void ShouldHaveCorrectPriceForSize(Size size, double price)
5887
[InlineData(Size.Large, 205)]
5988
public void ShouldHaveCorrectCaloriesForSize(Size size, uint cal)
6089
{
90+
SailorSoda soda = new SailorSoda();
91+
soda.Size = size;
92+
Assert.True(soda.Calories == cal);
6193
}
6294

6395
[Theory]
6496
[InlineData(true)]
6597
[InlineData(false)]
6698
public void ShouldHaveCorrectSpecialInstructions(bool includeIce)
6799
{
100+
SailorSoda soda = new SailorSoda();
101+
soda.Ice = includeIce;
102+
103+
if (!includeIce) Assert.Equal("Hold ice", soda.SpecialInstructions[0]);
104+
else Assert.Empty(soda.SpecialInstructions);
68105
}
69106

70107
[Theory]
@@ -93,6 +130,10 @@ public void ShouldHaveCorrectSpecialInstructions(bool includeIce)
93130
[InlineData(SodaFlavor.Watermelon, Size.Large, "Large Watermelon Sailor Soda")]
94131
public void ShouldHaveCorrectToStringBasedOnSizeAndFlavor(SodaFlavor flavor, Size size, string name)
95132
{
133+
SailorSoda soda = new SailorSoda();
134+
soda.Flavor = flavor;
135+
soda.Size = size;
136+
Assert.Equal(name, soda.ToString());
96137
}
97138
}
98139
}

0 commit comments

Comments
 (0)