示例#1
0
        public static bool GetAuthenticationService()
        {
            var authentication = new ApiCallQuotaDecorator(
                new LogDecorator(
                    new FailedCountDecorator(
                        new NotificationDecorator(
                            new AuthenticationService(new ProfileRepo(), new Sha256Adapter(), new OptService()),
                            new SlackAdapter()), new FailedCounter()), new NLogAdapter(), new FailedCounter()),
                new ApiCountQuota()).Verify("Kyo", "123456", "999999");

            return(authentication);
        }
        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;
        }