using System; namespace Solution { class FizzBuzz { public static string Convert(int input) { var divisableBy3 = input % 3 == 0; var divisableBy5 = input % 5 == 0; return (!divisableBy3 & !divisableBy5) ? input.ToString() : (divisableBy3 ? "Fizz" : string.Empty) + (divisableBy5 ? "Buzz" : string.Empty); } } }
- using System;
- namespace Solution {
- class FizzBuzz {
- public static string Convert(int input)
- {
var divisableBy3 = (input % 3 == 0);var divisableBy5 = (input % 5 == 0);- var divisableBy3 = input % 3 == 0;
- var divisableBy5 = input % 5 == 0;
- return (!divisableBy3 & !divisableBy5) ? input.ToString()
- : (divisableBy3 ? "Fizz" : string.Empty) + (divisableBy5 ? "Buzz" : string.Empty);
- }
- }
- }
using System; namespace Solution { class FizzBuzz { public static string Convert(int input) { bool divisableBy3 = (input % 3 == 0); bool divisableBy5 = (input % 5 == 0); return (!divisableBy3 & !divisableBy5) ? input.ToString() : (divisableBy3 ? "Fizz" : "") + (divisableBy5 ? "Buzz" : ""); } } }
- using System;
- namespace Solution {
- class FizzBuzz {
public static string convert(int input)- public static string Convert(int input)
- {
- bool divisableBy3 = (input % 3 == 0);
- bool divisableBy5 = (input % 5 == 0);
if (!divisableBy3 & !divisableBy5)return input.ToString();return (divisableBy3 ? "Fizz" : "") + (divisableBy5 ? "Buzz" : "");;- return (!divisableBy3 & !divisableBy5) ? input.ToString()
- : (divisableBy3 ? "Fizz" : "") + (divisableBy5 ? "Buzz" : "");
- }
- }
- }
namespace Solution { using NUnit.Framework; using System; // TODO: Replace examples and use TDD development by writing your own tests [TestFixture] public class SolutionTest { [Test] public void NotDivisibleByThreeOrFive() { Assert.That(FizzBuzz.Convert(1), Is.EqualTo("1")); Assert.That(FizzBuzz.Convert(7), Is.EqualTo("7")); } [Test] public void DivisibleByThree() { Assert.That(FizzBuzz.Convert(3), Is.EqualTo("Fizz")); Assert.That(FizzBuzz.Convert(12), Is.EqualTo("Fizz")); } [Test] public void DivisibleByFive() { Assert.That(FizzBuzz.Convert(5), Is.EqualTo("Buzz")); Assert.That(FizzBuzz.Convert(95), Is.EqualTo("Buzz")); } [Test] public void DivisibleByThreeAndFive() { Assert.That(FizzBuzz.Convert(15), Is.EqualTo("FizzBuzz")); Assert.That(FizzBuzz.Convert(90), Is.EqualTo("FizzBuzz")); } } }
- namespace Solution {
- using NUnit.Framework;
- using System;
- // TODO: Replace examples and use TDD development by writing your own tests
- [TestFixture]
- public class SolutionTest
- {
- [Test]
- public void NotDivisibleByThreeOrFive()
- {
Assert.That(FizzBuzz.convert(1), Is.EqualTo("1"));Assert.That(FizzBuzz.convert(7), Is.EqualTo("7"));- Assert.That(FizzBuzz.Convert(1), Is.EqualTo("1"));
- Assert.That(FizzBuzz.Convert(7), Is.EqualTo("7"));
- }
- [Test]
- public void DivisibleByThree()
- {
Assert.That(FizzBuzz.convert(3), Is.EqualTo("Fizz"));Assert.That(FizzBuzz.convert(12), Is.EqualTo("Fizz"));- Assert.That(FizzBuzz.Convert(3), Is.EqualTo("Fizz"));
- Assert.That(FizzBuzz.Convert(12), Is.EqualTo("Fizz"));
- }
- [Test]
- public void DivisibleByFive()
- {
Assert.That(FizzBuzz.convert(5), Is.EqualTo("Buzz"));Assert.That(FizzBuzz.convert(95), Is.EqualTo("Buzz"));- Assert.That(FizzBuzz.Convert(5), Is.EqualTo("Buzz"));
- Assert.That(FizzBuzz.Convert(95), Is.EqualTo("Buzz"));
- }
- [Test]
- public void DivisibleByThreeAndFive()
- {
Assert.That(FizzBuzz.convert(15), Is.EqualTo("FizzBuzz"));Assert.That(FizzBuzz.convert(90), Is.EqualTo("FizzBuzz"));- Assert.That(FizzBuzz.Convert(15), Is.EqualTo("FizzBuzz"));
- Assert.That(FizzBuzz.Convert(90), Is.EqualTo("FizzBuzz"));
- }
- }
- }