Skip to content

Instantly share code, notes, and snippets.

View marzoukali's full-sized avatar
:octocat:
Coding

Ahmed Ali marzoukali

:octocat:
Coding
  • Dublin, Ireland
View GitHub Profile
@marzoukali
marzoukali / unittest-example-10.cs
Created July 9, 2017 21:23
unittest-example-10
// This class will be used to create a simple GOF singletone object.
public class Security
{
private static Security _instance;
private string _userName;
private bool _isAdmin;
public static Security GetInstance()
{
@marzoukali
marzoukali / unittest-example-11.cs
Created July 9, 2017 21:28
unittest-example-10
// The solution is to refactor the GOF class to be instance class and let it use interface to make it easy to inject
// Then use the IOC/DI singleton way to ensue using only one instance of the object.
// The Interface
public interface ISecurity
{
string GetUserName();
bool IsAdmin();
}
@marzoukali
marzoukali / unittest-example-12.cs
Created July 9, 2017 21:29
unittest-example-12
[TestFixture]
public class PrintInvoiceCommandTests
{
private PrintInvoiceCommand _command;
private AutoMoqer _mocker;
private Invoice _invoice;
private const int InvoiceId = 1;
private const string UserName = "mrenze";