This file contains hidden or 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
| // 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() | |
| { |
This file contains hidden or 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
| // 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(); | |
| } |
This file contains hidden or 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
| [TestFixture] | |
| public class PrintInvoiceCommandTests | |
| { | |
| private PrintInvoiceCommand _command; | |
| private AutoMoqer _mocker; | |
| private Invoice _invoice; | |
| private const int InvoiceId = 1; | |
| private const string UserName = "mrenze"; |
OlderNewer