using System;
public class Kumite
{
public void PrintAnArray(string [] words) {
// Write all the words to the console
}
public int SumTheIntegers(int [] nums) {
// Add up all the integers and return the sum
}
}
namespace Solution {
using NUnit.Framework;
using System;
using System.IO;
// TODO: Replace examples and use TDD by writing your own tests
[TestFixture]
public class SolutionTest
{
//[Test]
public void PrintAnArrayTest()
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);
Kumite kumite = new Kumite();
string [] words = {"An", "array", "of", "strings"};
kumite.PrintAnArray(words);
string [] output = stringWriter.ToString().Split("\n");
Assert.AreEqual("An", output[0].Trim());
Assert.AreEqual("array", output[1].Trim());
Assert.AreEqual("of", output[2].Trim());
Assert.AreEqual("strings", output[3].Trim());
}
[Test]
public void SumTheIntegersTest()
{
Kumite kumite = new Kumite();
int [] nums = {10, 9, 8, 4, 5};
Assert.AreEqual(36, kumite.SumTheIntegers(nums));
}
}
}
using System;
public class Kumite
{
public void BasicVariables(int v) {
int count = 0;
// Write the name of the variable to the log
Console.WriteLine("<change this>");
// Write the type of the variable to the log
Console.WriteLine("<change this>");
// set the value of the variable to v (see the function parameters)
// <code here>
// Write the variable to the log
// <code here>
}
public string NamaeWa(string str) {
// Return "My name is <str>"
return "<change this>";
}
}
namespace Solution {
using NUnit.Framework;
using System;
using System.IO;
[TestFixture]
public class SolutionTest
{
[Test]
public void BasicVariablesTest()
{
var stringWriter = new StringWriter();
Console.SetOut(stringWriter);
Kumite kumite = new Kumite();
kumite.BasicVariables(12);
string [] output = stringWriter.ToString().Split("\n");
Assert.AreEqual("count", output[0].Trim());
Assert.AreEqual("int", output[1].Trim());
Assert.AreEqual("12", output[2].Trim());
}
[Test]
public void NamaeWaTest()
{
Kumite kumite = new Kumite();
Assert.AreEqual("My name is Taki", kumite.NamaeWa("Taki").Trim());
}
}
}
Practicing if else statements
using System;
public class Kumite
{
public bool MoreThan14(int num) {
// Create an integer variable with the value 14
// return true if your variable is bigger than num
}
// If the food is nasi lemak, return meal
// If the food is burger, return meal
// If the food is cendol or ice cream, return dessert
public string MealOrDessert(string food) {
return;
}
}
namespace Solution {
using NUnit.Framework;
using System;
// TODO: Replace examples and use TDD by writing your own tests
[TestFixture]
public class SolutionTest
{
[Test]
public void AmIOlderTest()
{
Kumite kumite = new Kumite();
Assert.AreEqual(true, kumite.MoreThan14(5));
Assert.AreEqual(false, kumite.MoreThan14(22));
Assert.AreEqual(true, kumite.MoreThan14(2));
}
[Test]
public void MealOrDessertTest()
{
Kumite kumite = new Kumite();
Assert.AreEqual("meal", kumite.MealOrDessert("nasi lemak"));
Assert.AreEqual("meal", kumite.MealOrDessert("burger"));
Assert.AreEqual("dessert", kumite.MealOrDessert("cendol"));
Assert.AreEqual("dessert", kumite.MealOrDessert("ice cream"));
}
}
}