Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3c5970e

Browse files
committed
Added given, when, then
1 parent 0eb9a4d commit 3c5970e

File tree

1 file changed

+21
-14
lines changed
  • CodingInterview/CodingInterview

1 file changed

+21
-14
lines changed

‎CodingInterview/CodingInterview/Tests.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,79 +118,86 @@ List<string> GetSummaryRanges(int [] inputArray)
118118
[Test]
119119
public void RemoveDuplicatesFromSortedArray_1()
120120
{
121+
//given
121122
var sortedArrayWithDuplicates = new int[] { 1, 3, 3, 6, 8, 8, 9 };
122123
var expectedSortedArrayWithoutDuplicates = new int[] { 1, 3, 6, 8, 9 };
123-
124+
//when
124125
var sortedArrayWithoutDuplicatesCalculated = RemoveDuplicates(sortedArrayWithDuplicates);
125-
126+
//then
126127
Assert.AreEqual(expectedSortedArrayWithoutDuplicates, sortedArrayWithoutDuplicatesCalculated);
127128
}
128129

129130
[Test]
130131
public void RemoveDuplicatesFromSortedArray_2()
131132
{
133+
//given
132134
var sortedArrayWithDuplicates = new int[] { 1, 3, 3, 3, 6, 8, 8, 9, 9, 9 };
133135
var expectedSortedArrayWithTwoDuplicates = new int[] { 1, 3, 3, 6, 8, 8, 9, 9 };
134-
136+
//when
135137
var sortedArrayWithTwoDuplicatesCalculated = LeaveTwoDuplicates(sortedArrayWithDuplicates);
136-
138+
//then
137139
Assert.AreEqual(expectedSortedArrayWithTwoDuplicates, sortedArrayWithTwoDuplicatesCalculated);
138140
}
139141

140142
[Test]
141143
public void RemoveElement_3()
142144
{
145+
//given
143146
var arrayWithElements = new int[] { 1, 5, 3, 3, 6, 1, 8, 3, 9, 7 };
144147
var expectedArrayWithElements = new int[] { 1, 5, 6, 1, 8, 9, 7 };
145148
var elementToRemove = 3;
146-
149+
//when
147150
var arrayWithRemoveElement = RemoveElement(arrayWithElements, elementToRemove);
148-
151+
//then
149152
Assert.AreEqual(expectedArrayWithElements, arrayWithRemoveElement);
150153
}
151154

152155
[Test]
153156
public void MoveZeros_4()
154157
{
158+
//given
155159
var arrayWithZeros = new int[] { 1, 0, 5, 0, 0, 3};
156160
var expectedArrayWithZerosInTheEnd = new int[] { 1, 5, 3, 0, 0, 0 };
157-
161+
//when
158162
var arrayWithRemoveElement = MoveZeros(arrayWithZeros);
159-
163+
//then
160164
Assert.AreEqual(expectedArrayWithZerosInTheEnd, arrayWithRemoveElement);
161165
}
162166

163167
[Test]
164168
public void ProductofArrayExceptSelf_7()
165169
{
170+
//given
166171
var inputArray = new int[] { 1, 2, 3, 4};
167172
var expectedArray = new int[] { 24, 12, 8, 6 };
168-
173+
//when
169174
var outputArray = GetProductofArrayExceptSelf(inputArray);
170-
175+
//then
171176
Assert.AreEqual(expectedArray, outputArray);
172177
}
173178

174179
[Test]
175180
public void MinimumSizeSubarraySum_8()
176181
{
182+
//given
177183
var inputArray = new int[] { 2, 3, 1, 2, 4, 3 };
178184
int n = 7;
179185
var expectedArray = new int[] { 4, 3 };
180-
186+
//when
181187
var outputArray = GetMinimumSizeSubarraySum(inputArray, n);
182-
188+
//then
183189
Assert.AreEqual(expectedArray, outputArray);
184190
}
185191

186192
[Test]
187193
public void SummaryRanges_9()
188194
{
195+
//given
189196
var inputArray = new int[] { 0, 1, 2, 4, 5, 7};
190197
var expectedArray = new string[] { "0->2", "4->5", "7" };
191-
198+
//when
192199
var outputArray = GetSummaryRanges(inputArray);
193-
200+
//then
194201
Assert.AreEqual(expectedArray, outputArray);
195202
}
196203
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /