using System.ComponentModel; using System; using System.IO; using System.Runtime.InteropServices; namespace TestProject1 { public class UnitTest1 { public class FizzBuzz { public string GetOutput(int number) { if ((number % 3 == 0) && (number % 5 == 0)) return "FizzBuzz"; if (number % 3 == 0) return "Fizz"; if (number % 5 == 0) return "Buzz"; return number.ToString(); } } public class EmailValidator { public bool IsValidate(string email) { if (!email.Contains("@") || !email.Contains(".")) { return false; } else { return true; } } } public class StackTests { Stack<int> stack; public StackTests() { stack = new Stack<int>(); } [Fact] public void bezitemkow() { var count = stack.Count; Assert.Equal(0, count); } [Fact] public void zitemkami() { stack.Push(42); var count = stack.Count; Assert.Equal(1, count); } } public class stringi { [Fact] public void czy_pierwszy_kot() { string[] zwierzeta = new string[] { "kot", "szynszyla", "owca", "osiol", "kuna" }; Assert.Equal("kot", zwierzeta[0]); } } [Fact] public void GetOutput_WhenInputIsDivisibleOnlyBy3_ShouldReturnFizz() { var fizzbuzz = new FizzBuzz(); var result = fizzbuzz.GetOutput(3); Assert.Contains(result, "Fizz"); } [Fact] public void GetOutput_WhenInputIsDivisibleOnlyBy5_ShouldReturnBuzz() { var fizzbuzz = new FizzBuzz(); var result = fizzbuzz.GetOutput(5); Assert.Contains(result, "FizzBuzz"); } [Fact] public void GetOutput_WhenInputIsDivisibleBy3And5_ShouldReturnFizzBuzz() { var fizzbuzz = new FizzBuzz(); var result = fizzbuzz.GetOutput(15); Assert.Contains(result, "FizzBuzz"); } [Fact] public void Iwalidate() { var walidacja = new EmailValidator(); bool result = walidacja.IsValidate("bob"); Assert.False(result); } } }