The immediate cause of the error is that you've omitted {
after namespace name:
namespace fizzbuzz { // <- this "{"
public class FizzBuzz {
...
}
} // <- and this "}"
However even if you amend this typo, you'll face another ones (you can't create an instance of a static class, FizzBuzz
hasn't required constructor etc.); let's start from a test, say this one:
[Test]
public void TestInputOneHundred() {
FizzBuzz fizzbuzz = new FizzBuzz(100);
Assert.AreEqual("Buzz", fizzbuzz.ToString());
}
you're creating FizzBuzz
isntance and then call ToString()
. So you have to implement something like this:
namespace fizzbuzz { // <- do not forget "{"
// Not static! You (== your test) want to create instances
public class FizzBuzz {
// create, passing int (exactly as test wants)
public FizzBuzz(int value) {
Value = value;
}
// ToString will want the value
public int Value {get; set;}
// ToString to call in the test
public override ToString() {
if (Value % 5 == 0)
return "Buzz";
return Value.ToString();
}
}
}
And the test passed. Run another one, e.g.
[Test]
public void TestInputThree() {
FizzBuzz fizzbuzz = new FizzBuzz(3);
Assert.AreEqual("Fizz", fizzbuzz.ToString());
}
To pass this one you have to modify ToString()
into
public override ToString() {
if (Value % 5 == 0)
return "Buzz";
else if (Value % 3 == 0) // for the 2nd test
return "Fizz";
return Value.ToString();
}
And so on until all the test are passed.