Skip to content

Instantly share code, notes, and snippets.

Avatar

Stefan Mehnert zs40x

View GitHub Profile
View DIP_1_Program.cs
using UserEMailNotificationSender.BL;
using UserEMailNotificationSender.Model;
namespace UserEMailNotificationSender
{
class Program
{
static void Main(string[] args)
{
User aUser = new User("TheUser", "the_user@mail_service.com", false);
View DIP_2_SMTPNotificationSender.cs
using UserEMailNotificationSender.Infrastucture;
using UserEMailNotificationSender.Model;
namespace UserEMailNotificationSender.BL
{
class SMTPNotificationSender
{
SMTPClient smtpClient = new SMTPClient();
public void sendNotificationForUser(User userToNotify)
View DIP_3_NotificationService.cs
using Core.Interfaces;
using Core.Model;
namespace Core.Services
{
public class NotificationService
{
SendMail sendMail;
public NotificationService(SendMail _sendMail)
View DIP_4_SendMailInterface.cs
namespace Core.Interfaces
{
public interface SendMail
{
void sendMail(string recipient, string subject, string message);
}
}
View DIP_5_Refactored_Program.cs
using Core.Model;
using Core.Services;
using Infrastucture.Services;
using System;
namespace UserEMailNotificationSender
{
public class Program
{
static void Main(string[] args)
View DIP_6_NotificationService_sendNotificationForUser.cs
[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);
View SensorDevice.cs
interface SensorDevice
{
void powerOff();
void enable();
void disable();
bool isEnabled();
DateTime isEnabledSince();
int getFirmwareVersion();
long getSystemUptime();
int getLastReading();
View SensorDeviceInterfaces.cs
namespace SensorDevices
{
public interface SensorDevice : DeviceControl, DeviceState, SensorReading
{}
public interface DeviceControl
{
void powerOff();
int getFirmwareVersion();
long getSystemUptime();
View SensorConsoleTest.cs
using SensorDevices;
using FakeSensors;
using System;
namespace Console_SensorDevice_Test
{
static class Program
{
static void Main()
{
View async_await_example.cs
private async void DoWhoisLookup()
{
EnableInput(false);
try
{
var googleWhoisLookup = new WhoisLookup(tbHostToLookup.Text);
// initiate HTTP request asynchronously
Task<string> getWhoisInfoTask = googleWhoisLookup.GetWhoisInformationsAsync();