This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void IntroduceMethodShouldWorkCorrectly() | |
{ | |
var sut = new Employee("Alice", "Programmer", 100000); | |
var expected = "Hi! My name is Alice and I work as a Programmer."; | |
string result = sut.Introduce(); | |
Assert.AreEqual(expected, result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void IntroduceMethodShouldWorkCorrectly() | |
{ | |
// arrange | |
var sut = new Employee("Alice", "Programmer", 100000); | |
var expected = "Hi! My name is Alice and I work as a Programmer."; | |
// act | |
string result = sut.Introduce(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void GiveNegativeRaiseShouldHaveNoEffectOnSalary() | |
{ | |
// arrange | |
var raise = -10; | |
var salary = 100; | |
var sut = new Employee("Bob", "Tester", salary); | |
// act | |
sut.GiveRaise(raise); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IntExtensions | |
{ | |
public static bool Even(this int value) | |
{ | |
return value % 2 == 0; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension IntExtension extends int | |
{ | |
public bool Even => this % 2 == 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x = int.Parse(Console.Readline()); | |
if (x.Even) | |
{ | |
Console.WriteLine("You’ve typed an even number."); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IDisplayService | |
{ | |
void DisplayMessage(string message) { WriteLine(message); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int CalculateSquareOfAge(Person p) | |
{ | |
int age = p.Age; | |
return age * age; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int CalculateSquareOfAge(Person? p) | |
{ | |
int age = p.Age; | |
return age * age; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int CalculateSquareOfAge(Person? p) | |
{ | |
var result = 0; | |
if (p != null) | |
result = p.Age * p.Age; | |
return result; | |
} |
OlderNewer