-
Notifications
You must be signed in to change notification settings - Fork 0
/
testclass.cs
100 lines (69 loc) · 2.77 KB
/
testclass.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
using Xunit;
using myapp;
using System.Collections.Generic;
public class testclass
{
[Fact]
public void PassingPropertyGetName(){
thingToSteal iron = new thingToSteal("iron",4,3);
Assert.Equal("iron",iron.GetName);
}
[Fact]
public void PassingPropertyGetWeight(){
thingToSteal iron = new thingToSteal("iron",4,3);
Assert.Equal(3,iron.GetWeight);
}
[Fact]
public void PassingPropertyGetValue(){
thingToSteal iron = new thingToSteal("iron",4,3);
Assert.Equal(4,iron.GetValue);
}
[Fact]
public void PassingPropertyGetRatio(){
thingToSteal iron = new thingToSteal("iron",3,3);
Assert.Equal(1,iron.GetRatio);
}
[Fact]
public void PassingFracKnapSackSolver(){
thingToSteal iron = new thingToSteal("iron",3,3);
thingToSteal copper = new thingToSteal("copper",2,3);
thingToSteal bronze = new thingToSteal("bronze",10,4);
thingToSteal gold = new thingToSteal("gold",15,3);
List<thingToSteal> ItemList = new List<thingToSteal>();
ItemList.Add(iron);
ItemList.Add(copper);
ItemList.Add(bronze);
ItemList.Add(gold);
List<(float, thingToSteal)> actual = new List<(float, thingToSteal)>();
actual.Add((3,gold));
actual.Add((2,bronze));
Assert.Equal(actual,program.FracKnapSackSolver(ItemList,5));
}
[Theory]
[InlineData("iron",3,3,"copper",2,3,1)]
[InlineData("iron",3,2,"copper",2,2,1)]
[InlineData("iron",6,2,"copper",2,3,1)]
public void PassingCompareByRatioXBiggerThanY(string x1, float x2, float x3, string y1, float y2, float y3, int exp){
thingToSteal obj1 = new thingToSteal(x1,x2,x3);
thingToSteal obj2 = new thingToSteal(y1,y2,y3);
Assert.Equal(exp,thingToSteal.CompareByRatio(obj1,obj2));
}
[Theory]
[InlineData("iron",2,3,"copper",3,3,-1)]
[InlineData("iron",1,1,"copper",5,2,-1)]
[InlineData("iron",4,1,"copper",9,2,-1)]
public void PassingCompareByRatioXLessThanY(string x1, float x2, float x3, string y1, float y2, float y3, int exp){
thingToSteal obj1 = new thingToSteal(x1,x2,x3);
thingToSteal obj2 = new thingToSteal(y1,y2,y3);
Assert.Equal(exp,thingToSteal.CompareByRatio(obj1,obj2));
}
[Theory]
[InlineData("iron",2,2,"copper",3,3,0)]
[InlineData("iron",1,1,"copper",5,5,0)]
[InlineData("iron",1,4,"copper",2,8,0)]
public void PassingCompareByRatioXEqualY(string x1, float x2, float x3, string y1, float y2, float y3, int exp){
thingToSteal obj1 = new thingToSteal(x1,x2,x3);
thingToSteal obj2 = new thingToSteal(y1,y2,y3);
Assert.Equal(exp,thingToSteal.CompareByRatio(obj1,obj2));
}
}