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
using System; | |
namespace ConsoleApplication | |
{ | |
public class Program | |
{ | |
static void Main() | |
{ | |
Console.WriteLine(getWithTernaryOperator()); | |
Console.WriteLine(getWithNullCoalescingOperator()); |
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 class Person | |
{ | |
// Example 1: manually implemented property | |
private string _name; | |
public string Name | |
{ | |
get | |
{ | |
return _name; |
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 class Money | |
{ | |
public decimal Amount { get; private set; } = 20m; | |
public void doStuff() | |
{ | |
Amount *= 2; | |
} | |
} | |
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
class WhoisLookup | |
{ | |
private readonly string webApiBaseAddress = "http://api.hackertarget.com/whois/?q="; | |
public string HostToLookup { get; private set; } | |
public WhoisLookup(string hostToLookup) | |
{ | |
HostToLookup = hostToLookup; | |
} |
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
private async void DoWhoisLookup() | |
{ | |
EnableInput(false); | |
try | |
{ | |
var googleWhoisLookup = new WhoisLookup(tbHostToLookup.Text); | |
// initiate HTTP request asynchronously | |
Task<string> getWhoisInfoTask = googleWhoisLookup.GetWhoisInformationsAsync(); |
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
using SensorDevices; | |
using FakeSensors; | |
using System; | |
namespace Console_SensorDevice_Test | |
{ | |
static class Program | |
{ | |
static void Main() | |
{ |
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
namespace SensorDevices | |
{ | |
public interface SensorDevice : DeviceControl, DeviceState, SensorReading | |
{} | |
public interface DeviceControl | |
{ | |
void powerOff(); | |
int getFirmwareVersion(); | |
long getSystemUptime(); |
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 SensorDevice | |
{ | |
void powerOff(); | |
void enable(); | |
void disable(); | |
bool isEnabled(); | |
DateTime isEnabledSince(); | |
int getFirmwareVersion(); | |
long getSystemUptime(); | |
int getLastReading(); |
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
[TestMethod] | |
public void isNonPremiumUserMailSentAndValid() | |
{ | |
var user = new User("A", "A@B.com", false); | |
var expectedSubject = "Notification"; | |
var expectedMessage = "Dear A this is a Notification!"; | |
var sendMail = Mock.Create<SendMail>(); | |
new NotificationService(sendMail).sendNotificationForUser(user); |
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
using Core.Model; | |
using Core.Services; | |
using Infrastucture.Services; | |
using System; | |
namespace UserEMailNotificationSender | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) |