-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeWarsKata.Tests.cs
230 lines (207 loc) · 7.43 KB
/
CodeWarsKata.Tests.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// using System;
// using System.Collections.Generic;
using Xunit;
using CodeWarsKata.ClassLib;
namespace tests
{
public class CodeWarsKata_Tests
{
private readonly CodeWarsKataFunctions _cwk;
public CodeWarsKata_Tests() {
_cwk = new CodeWarsKataFunctions();
}
[Theory]
[InlineData("Zachary Howard", "Z.H")]
[InlineData("Aaron Mina", "A.M")]
[InlineData("christianne Mina", "C.M")]
[InlineData("richard mina", "R.M")]
public void AbbrevNameTest(string value, string expected)
{
var result = _cwk.AbbrevName(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(true, "Yes")]
[InlineData(false, "No")]
public void BoolToWordTest(bool value, string expected)
{
var result = _cwk.BoolToWord(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(1, "Odd")]
[InlineData(2, "Even")]
public void EvenOrOddTest(int value, string expected)
{
var result = _cwk.EvenOrOdd(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(2, 1, 2, 6)]
[InlineData(1, 1, 1, 3)]
[InlineData(2, 1, 1, 4)]
[InlineData(1, 2, 3, 9)]
[InlineData(5, 1, 3, 020)]
[InlineData(10, 05, 06, 300)]
public void ExpressionsMatterTest(int valueA, int valueB, int valueC, int expected)
{
var result = _cwk.ExpressionsMatter(valueA, valueB, valueC);
Assert.Equal(expected, result);
}
[Theory]
[InlineData("0123456789", "0000011111")]
[InlineData("9126345078129", "1001001011001")]
[InlineData("85949039984572667471", "11101001110110111010")]
[InlineData("0594837264759860397215", "0110101010111110011001")]
public void FakeBinaryTest(string value, string expected)
{
var result = _cwk.FakeBin(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(new double[] { 1, 2, 3 }, 2)]
[InlineData(new double[] { 4, 5, 6, 28, 2 }, 9)]
[InlineData(new double[] { 56, 234, 655, 9 }, 238.5)]
public void FindAverageTest(double[] value, double expected)
{
var result = _cwk.FindAverage(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData("Hello now brown cow!", 3)]
[InlineData("Hello, I love you won't you tell me your name!", 1)]
[InlineData("You say goodbye and I say Hello!", 1)]
[InlineData("Raining blood!", 6)]
public void FindShortTest(string value, int expected)
{
var result = _cwk.FindShort(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(new int[] { 1, 2, 3, -4, 5 }, -4)]
[InlineData(new int[] { 1, -2, 3, -4, -50 }, -50)]
[InlineData(new int[] { 1, 20, 83, -74, 5 }, -74)]
[InlineData(new int[] { -1, 20, 33, 45, 56 }, -1)]
public void FindSmallestIntegerTest(int[] value, int expected)
{
var result = _cwk.FindSmallestInteger(value);
Assert.Equal(expected, result);
}
[Fact]
public void GreetTest()
{
var result = _cwk.greet();
Assert.Equal("hello world", result);
}
[Theory]
[InlineData("3", true)]
[InlineData(" 3 ", true)]
[InlineData("-3", true)]
[InlineData("3.14", true)]
[InlineData("-3.14", true)]
[InlineData("3 6", false)]
[InlineData("3-4", false)]
[InlineData("zero", false)]
public void IsDigitTest(string value, bool expected)
{
var result = _cwk.IsDigit(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(-1, -1)]
[InlineData(5, -5)]
[InlineData(0, 0)]
public void MakeNegativeTest(int value, int expected)
{
var result = _cwk.MakeNegative(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(1, 2, 2)]
[InlineData(5, 6, 30)]
[InlineData(45, 50, 2250)]
[InlineData(4, 300, 1200)]
public void MultiplyTest(int value1, int value2, int expected)
{
var result = _cwk.Multiply(value1, value2);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(-1, 1)]
[InlineData(5, -5)]
[InlineData(0, 0)]
public void OppositeTest(int value, int expected)
{
var result = _cwk.Opposite(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(new int[] { 1, 2, 3, 4, 5 }, 15)]
[InlineData(new int[] { 1, -2, 3, 4, 5 }, 13)]
[InlineData(new int[] { -1, 2, 3, 4, -5 }, 9)]
[InlineData(new int[] { }, 0)]
[InlineData(new int[] { -1, -2, -3, -4, -5 }, 0)]
public void PositiveSumTest(int[] value, int expected)
{
var result = _cwk.PositiveSum(value);
Assert.Equal(expected, result);
}
// TODO: Figure out how to pass in List<int> or new List<int>
// Two using statemtents are commented out from this as well
// [Theory]
// [InlineData(List<int> {1, 2, 3, 4, 5}, List<int> {2, 3, 4, 5})]
// [InlineData(List<int> {10, -2, 3, 4, 55, -400}, List<int> {10, -2, 3, 4, 55})]
// [InlineData(List<int> {2, 2, 1, 2, 1}, List<int> {2, 2, 2, 1})]
// [InlineData(List<int> {}, List<int> {})]
// public void RemoveSmallestTest(List<int> value, List<int> expected)
// {
// var result = _cwk.RemoveSmallest(value);
// Assert.Equal(expected, result);
// }
[Theory]
[InlineData(6, "Hello", "HelloHelloHelloHelloHelloHello")]
[InlineData(10, "I", "IIIIIIIIII")]
public void repeatStrTest(int value1, string value2, string expected)
{
var result = _cwk.repeatStr(value1, value2);
Assert.Equal(expected, result);
}
[Theory]
[InlineData("Hello World", "olleH dlroW")]
[InlineData("I love you", "I evol uoy")]
[InlineData("Lucille is so beautiful!", "ellicuL si os !lufituaeb")]
public void ReverseWordsTest(string value, string expected)
{
var result = _cwk.ReverseWords(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(new int[] {1, 2}, 5)]
[InlineData(new int[] {2, 3, 4}, 29)]
[InlineData(new int[] {5, 6, 7}, 110)]
[InlineData(new int[] {3, 4, 5}, 50)]
public void SquareSumTest(int[] value, int expected)
{
var result = _cwk.SquareSum(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(1, 1)]
[InlineData(8, 36)]
[InlineData(22, 253)]
[InlineData(100, 5050)]
public void SummationTest(int value, int expected)
{
var result = _cwk.Summation(value);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(1, "One")]
[InlineData(5, "Five")]
public void SwitchItUpTest(int value, string expected)
{
var result = _cwk.SwitchItUp(value);
Assert.Equal(expected, result);
}
}
}