-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoatFood.cs
61 lines (48 loc) · 1.86 KB
/
GoatFood.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
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PrimitiveTypes
{
[TestClass]
public class GoatFood
{
[TestMethod]
[TestCategory("08_Goat_Food")]
public void Compute_Food_Needed_For_Tim_Data() {
double rDays = 2;
double rGoats = 4;
double rNeededHayInKg = 8;
double neededHayInKg = ComputeNeededHayInKg(rDays, rGoats, rNeededHayInKg, 1, 2);
Assert.AreEqual(2, neededHayInKg);
}
[TestMethod]
[TestCategory("08_Goat_Food")]
public void Compute_Food_Needed_For_Zero_Days() {
double rDays = 0;
double rGoats = 4;
double rNeededHayInKg = 8;
double neededHayInKg = ComputeNeededHayInKg(rDays, rGoats, rNeededHayInKg, 1, 2);
Assert.AreEqual(0, neededHayInKg);
}
[TestMethod]
[TestCategory("08_Goat_Food")]
public void Compute_Food_Needed_For_Zero_Goats() {
double rDays = 2;
double rGoats = 0;
double rNeededHayInKg = 8;
double neededHayInKg = ComputeNeededHayInKg(rDays, rGoats, rNeededHayInKg, 1, 2);
Assert.AreEqual(0, neededHayInKg);
}
[TestMethod]
[TestCategory("08_Goat_Food")]
public void Compute_Food_Needed_For_Goats_When_All_Values_More_Than_Zero() {
double rDays = 2;
double rGoats = 4;
double rNeededHayInKg = 8;
double neededHayInKg = ComputeNeededHayInKg(rDays, rGoats, rNeededHayInKg, 1, 2);
Assert.AreEqual(2, neededHayInKg);
}
private double ComputeNeededHayInKg(double rDays, double rGoats, double rNeededHayInKg, double days, double goats) {
return rGoats > 0 && rDays > 0 ? (days * goats * rNeededHayInKg) / (rDays * rGoats) : 0;
}
}
}