public void Setup() { _profile = Substitute.For <IProfile>(); _hash = Substitute.For <IHash>(); _otpService = Substitute.For <IOTPService>(); _failedCounter = Substitute.For <IFailedCounter>(); _logger = Substitute.For <ILogger>(); _notification = Substitute.For <INotification>(); var authenticationService = new AuthenticationService( _hash, _otpService, _profile); var notificationDecorator = new NotificationDecorator(authenticationService, _notification); var failedCounterDecorator = new FailedCounterDecorator(notificationDecorator, _failedCounter); _authentication = new LogFailedCountDecorator(failedCounterDecorator, _failedCounter, _logger); }
public void Setup() { //Use NSubstitute to mock objects. _profile = Substitute.For <IProfile>(); _otpRemoteProxy = Substitute.For <IOtp>(); _hash = Substitute.For <IHash>(); _notification = Substitute.For <INotification>(); _failedCounter = Substitute.For <IFailedCounter>(); _logger = Substitute.For <ILogger>(); var authenticationService = new AuthenticationService(_profile, _hash, _otpRemoteProxy); var notificationDecorator = new NotificationDecorator(authenticationService, _notification); var logDecorator = new FailedCounterDecorator(notificationDecorator, _failedCounter); _authentication = new LogDecorator(logDecorator, _failedCounter, _logger); }
public void Setup() { _logger = Substitute.For <ILogger>(); _profile = Substitute.For <IProfile>(); _optService = Substitute.For <IOtp>(); _hash = Substitute.For <IHash>(); _notification = Substitute.For <INotification>(); _failedCounter = Substitute.For <IFailedCounter>(); _apiCountQuota = Substitute.For <IApiCountQuota>(); var authenticationService = new AuthenticationService(_profile, _hash, _optService); var notificationDecorator = new NotificationDecorator(authenticationService, _notification); var failedCountDecorator = new FailedCountDecorator(notificationDecorator, _failedCounter); var logDecorator = new LogDecorator(failedCountDecorator, _logger, _failedCounter); var apiCallQuotaDecorator = new ApiCallQuotaDecorator(logDecorator, _apiCountQuota); _authentication = apiCallQuotaDecorator; }
public void SetUp() { _profile = Substitute.For <IProfile>(); _hash = Substitute.For <IHash>(); _otpService = Substitute.For <IOtpService>(); _failedCounter = Substitute.For <IFailedCounter>(); _notification = Substitute.For <INotification>(); _logger = Substitute.For <ILogger>(); //先初始化一個最基本的Service var authentication = new AuthenticationService(_profile, _hash, _otpService); //然後裝飾他,越後面越先執行 var notificationDecorator = new NotificationDecorator(authentication, _notification); var failedCounterDecorator = new FailedCounterDecorator(notificationDecorator, _failedCounter); _authentication = new LogFailedCountDecorator(failedCounterDecorator, _failedCounter, _logger); }
public void SetUp() { _profile = Substitute.For <IProfile>(); _otp = Substitute.For <IOtp>(); _hash = Substitute.For <IHash>(); _notification = Substitute.For <INotification>(); _logger = Substitute.For <ILogger>(); _failedCounter = Substitute.For <IFailedCounter>(); _apiUserQuotaV2 = Substitute.For <IApiUserQuotaV2>(); var authenticationService = new AuthenticationService(_profile, _hash, _otp); var checkUseTimeDecorator = new ApiCheckTimeDecorator(authenticationService, _apiUserQuotaV2); var notificationDecorator = new NotificationDecorator(checkUseTimeDecorator, _notification, _logger); var failedCounterDecorator = new FailedCounterDecorator(notificationDecorator, _failedCounter); var logDecorator = new LogDecorator(failedCounterDecorator, _failedCounter, _logger); _authentication = logDecorator; }
public void SetUp() { _profile = Substitute.For <IProfile>(); _hash = Substitute.For <IHash>(); _otpService = Substitute.For <IOtpService>(); _failedCounter = Substitute.For <IFailedCounter>(); _notification = Substitute.For <INotification>(); _logger = Substitute.For <ILogger>(); IAuthenticationService authentication = new AuthenticationService( _profile, _hash, _otpService); authentication = new FailedCounterDecorator(authentication, _failedCounter); authentication = new NotificationDecorator(authentication, _notification); authentication = new LogDecorator(authentication, _logger, _failedCounter); _authenticationService = authentication; }
public void SetUp() { _profile = Substitute.For <IProfile>(); _hash = Substitute.For <IHash>(); _otpService = Substitute.For <IOtpService>(); _failedCounter = Substitute.For <IFailedCounter>(); _notification = Substitute.For <INotification>(); _logger = Substitute.For <ILogger>(); // 主體 var authenticationService = new AuthenticationService( _profile, _hash, _otpService); // 主體(_authentication)以界面作接口 // authenticationService 配上 Notification => notificationDecorator var notificationDecorator = new NotificationDecorator(authenticationService, _notification); // notificationDecorator 配上 FailedCounterDecorator => failedCounterDecorator var failedCounterDecorator = new FailedCounterDecorator(notificationDecorator, _failedCounter); // failedCounterDecorator 配上 LogFaileCounterDecorator => _authentication _authentication = new LogFaileCounterDecorator(failedCounterDecorator, _failedCounter, _logger); }