public async Task Run_RawOccurrancesProcessedOnceForNonUniqueResponseScheduleUntilHoursBackToRetrieve() { #region arrange IDateTimeOffsetProvider dateTimeOffsetProvider = Substitute.For <IDateTimeOffsetProvider>(); DateTimeOffset now = DateTimeOffset.MaxValue.Subtract(TimeSpan.FromSeconds(86399)); dateTimeOffsetProvider.UtcNow.Returns(now); IRadiocomClient client = Substitute.For <IRadiocomClient>(); IRadiocomRepository repository = Substitute.For <IRadiocomRepository>(); IOptions <RadiocomDataCollectorEngineOptions> optionsSnapshot = Substitute.For <IOptions <RadiocomDataCollectorEngineOptions> >(); RadiocomDataCollectorEngineOptions options = new RadiocomDataCollectorEngineOptions() { HoursBackToRetrive = 5 }; optionsSnapshot.Value.Returns(options); Task <StationRecentlyPlayedResponse> response = Task.FromResult(GetStationRecentlyPlayedResponse()); client .StationRecentlyPlayed(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <ApiWrapper.Radiocom.DayOfWeek>()) .Returns(response); repository.ProcessRawOccurrances(Arg.Any <IEnumerable <RawArtistWorkStationOccurrence> >()) .Returns(response.Result.Schedule.Count, 0); RadiocomDataCollectorEngine engine = new RadiocomDataCollectorEngine(client, repository, optionsSnapshot, dateTimeOffsetProvider, log); #endregion arrange #region act await engine.Run(); #endregion act #region assert List <ICall> clientCalls = client.ReceivedCalls().AsList(); await repository.Received(1).ProcessRawOccurrances(Arg.Any <IEnumerable <RawArtistWorkStationOccurrence> >()); Assert.AreEqual(902, (int)clientCalls[0].GetArguments()[0]); Assert.AreEqual(902, (int)clientCalls[1].GetArguments()[0]); Assert.AreEqual(902, (int)clientCalls[2].GetArguments()[0]); Assert.AreEqual(902, (int)clientCalls[3].GetArguments()[0]); Assert.AreEqual(902, (int)clientCalls[4].GetArguments()[0]); Assert.AreEqual(now.Hour, (int)clientCalls[0].GetArguments()[1]); Assert.AreEqual(now.AddHours(-1).Hour, (int)clientCalls[1].GetArguments()[1]); Assert.AreEqual(now.AddHours(-2).Hour, (int)clientCalls[2].GetArguments()[1]); Assert.AreEqual(now.AddHours(-3).Hour, (int)clientCalls[3].GetArguments()[1]); Assert.AreEqual(now.AddHours(-4).Hour, (int)clientCalls[4].GetArguments()[1]); now = ConvertTime(now); Assert.AreEqual(now.DayOfWeek.ToRadiocomDayOfWeek().ToString(), clientCalls[0].GetArguments()[2].ToString()); Assert.AreEqual(now.DayOfWeek.ToString(), clientCalls[1].GetArguments()[2].ToString()); Assert.AreEqual(now.DayOfWeek.ToString(), clientCalls[2].GetArguments()[2].ToString()); Assert.AreEqual(now.DayOfWeek.ToString(), clientCalls[3].GetArguments()[2].ToString()); Assert.AreEqual(now.DayOfWeek.ToString(), clientCalls[4].GetArguments()[2].ToString()); #endregion assert }
public AuthenticationTicketProvider(ITokenHttpClient tokenHttpClient, IDateTimeOffsetProvider dateTimeOffsetProvider) { this.tokenHttpClient = tokenHttpClient; this.dateTimeOffsetProvider = dateTimeOffsetProvider; this.semaphore = new SemaphoreSlim(1); }
public TilesController(IMetricService metricService, ITileService tileService, IIntegerTileService integerTileService, IDateTimeOffsetProvider dateTimeOffsetProvider) { _metricService = metricService ?? throw new ArgumentNullException(nameof(metricService)); _tileService = tileService ?? throw new ArgumentNullException(nameof(tileService)); _integerTileService = integerTileService ?? throw new ArgumentNullException(nameof(integerTileService)); _dateTimeOffsetProvider = dateTimeOffsetProvider ?? throw new ArgumentNullException(nameof(dateTimeOffsetProvider)); }
private MeterMetric(string eventType, TimeUnit rateUnit, IDateTimeOffsetProvider dateTimeOffsetProvider) { _dateTimeOffsetProvider = dateTimeOffsetProvider ?? new DateTimeOffsetProvider(); EventType = eventType; RateUnit = rateUnit; }
public Chain(IDateTimeOffsetProvider dateTimeOffsetProvider) { DateTimeOffsetProvider = dateTimeOffsetProvider; Blocks = new List <Block>(); var genesisBlock = new Block(new DateTimeOffset(), 0, "", null); Blocks.Add(genesisBlock); }
public DateTimePassedEvaluator(IDateTimeOffsetProvider dateTimeOffsetProvider) { if (dateTimeOffsetProvider == null) { throw new ArgumentNullException("dateTimeOffsetProvider"); } this.dateTimeOffsetProvider = dateTimeOffsetProvider; }
public Trip(Guid id, string name, string tripDestination, DateTimeOffset startDate, DateTimeOffset endDate, IDateTimeOffsetProvider dateTimeOffsetProvider) { Id = id; _customerTrips = new HashSet <CustomerTrip>(); SetInitialDataOrFail(name, tripDestination, dateTimeOffsetProvider); SetDatesOrFail(startDate.ToUniversalTime(), endDate.ToUniversalTime()); TripStatus = TripStatus.Active; }
public TripService(ITripRepository tripRepository, ICustomerRepository customerRepository, ITraveloMapper mapper, IDateTimeOffsetProvider dateTimeOffsetProvider) { _tripRepository = tripRepository; _mapper = mapper; _dateTimeOffsetProvider = dateTimeOffsetProvider; _customerRepository = customerRepository; }
/// <param name="reservoirSize">The number of samples to keep in the sampling reservoir</param> /// <param name="alpha">The exponential decay factor; the higher this is, the more biased the sample will be towards newer values</param> /// <param name="dateTimeOffsetProvider"></param> public ExponentiallyDecayingSample(int reservoirSize, double alpha, IDateTimeOffsetProvider dateTimeOffsetProvider = null) { _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); _values = new ConcurrentDictionary <double, long>(); _alpha = alpha; _reservoirSize = reservoirSize; _dateTimeOffsetProvider = dateTimeOffsetProvider ?? new DateTimeOffsetProvider(); Clear(); }
public AuthenticationTicketProvider( IAuthenticationManager authenticationManager, IDateTimeOffsetProvider dateTimeOffsetProvider, ITokenHttpClient tokenHttpClient, IOptionsProvider <AspNetCoreAuthorizationCodeFlowOptions> optionsProvider) { this.authenticationManager = authenticationManager; this.dateTimeOffsetProvider = dateTimeOffsetProvider; this.tokenHttpClient = tokenHttpClient; this.optionsProvider = optionsProvider; }
public void SetUp() { _dateTimeOffsetProvider = new DateTimeOffsetProvider(); _n1Chain = new Chain(_dateTimeOffsetProvider); _n2Chain = new Chain(_dateTimeOffsetProvider); _n3Chain = new Chain(_dateTimeOffsetProvider); _state1 = new AggregatedState <string>(_n1Chain); _state2 = new AggregatedState <string>(_n2Chain); _state3 = new AggregatedState <string>(_n3Chain); }
private void SetInitialDataOrFail(string name, string tripDestination, IDateTimeOffsetProvider dateTimeOffsetProvider) { if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(tripDestination) || dateTimeOffsetProvider == null) { throw new DomainException(DomainErrorCodes.ArgumentNullOrEmpty, null, "Trip name, destination or dateTimeOffsetProvider is null!"); } _dateTimeOffsetProvider = dateTimeOffsetProvider; Name = name; TripDestination = tripDestination; }
public static MeterMetric New(string eventType, TimeUnit rateUnit, IDateTimeOffsetProvider dateTimeOffsetProvider = null) { var meter = new MeterMetric(eventType, rateUnit, dateTimeOffsetProvider); Task.Run(async() => { while (!meter._token.IsCancellationRequested) { await Task.Delay(Interval, meter._token.Token); meter.Tick(); } }, meter._token.Token); return(meter); }
public RadiocomDataCollectorEngine( IRadiocomClient client, IRadiocomRepository radiocomRepository, IOptions <RadiocomDataCollectorEngineOptions> radiocomDataCollectorEngineOptions, IDateTimeOffsetProvider dateTimeOffsetProvider, ILogger <RadiocomDataCollectorEngine> log, IPublishCollectorEventCompleted publishCollectorEventCompleted) { _client = client; _radiocomRepository = radiocomRepository; _radiocomDataCollectorEngineOptions = radiocomDataCollectorEngineOptions.Value; _dateTimeOffsetProvider = dateTimeOffsetProvider; _log = log; _publishCollectorEventCompleted = publishCollectorEventCompleted; }
public AuthenticationService(IDateTimeOffsetProvider provider, IMapper mapper, IEmailService emailService, AccountRepository repository, AccessTokenHistoryRepository tokenHistoryRepository, LocalizerSettings settings) { _provider = provider; _mapper = mapper; _emailService = emailService; _repository = repository; _tokenHistoryRepository = tokenHistoryRepository; _secretSettings = settings.Authentication; _signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_secretSettings.TokenSigningKey)); _signingCredentials = new SigningCredentials(_signingKey, SecurityAlgorithms.HmacSha256); }
public AuthenticationTicketProvider( IAuthenticationTicketStorage authenticationTicketStorage, IAuthorizationProvider <string> authorizationProvider, ITokenProxyClient tokenProxyClient, IUserHttpClient userHttpClient, IDateTimeOffsetProvider dateTimeOffsetProvider) { this.authenticationTicketStorage = authenticationTicketStorage; this.authorizationProvider = authorizationProvider; this.tokenProxyClient = tokenProxyClient; this.userHttpClient = userHttpClient; this.dateTimeOffsetProvider = dateTimeOffsetProvider; this.semaphore = new SemaphoreSlim(1); this.locker = new object(); }
public PluginBackgroundWorker( IDataPluginLoader pluginLoader, ILogger <PluginBackgroundWorker> logger, IDateTimeOffsetProvider dateTimeProvider, MetricPluginHandler metricPluginHandler, WeatherPluginHandler weatherPluginHandler, IntegerPluginHandler integerPluginHandler, HeartBeatPluginHandler heartBeatPluginHandler) { _pluginLoader = pluginLoader ?? throw new ArgumentNullException(nameof(pluginLoader)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _dateTimeProvider = dateTimeProvider ?? throw new ArgumentNullException(nameof(dateTimeProvider)); _metricPluginHandler = metricPluginHandler ?? throw new ArgumentNullException(nameof(metricPluginHandler)); _weatherPluginHandler = weatherPluginHandler ?? throw new ArgumentNullException(nameof(weatherPluginHandler)); _integerPluginHandler = integerPluginHandler ?? throw new ArgumentNullException(nameof(integerPluginHandler)); _heartBeatPluginHandler = heartBeatPluginHandler ?? throw new ArgumentNullException(nameof(heartBeatPluginHandler)); }
/// <summary> /// <para> /// Creates a <see cref="Builder" /> with <paramref name="configurement" />. /// </para> /// </summary> /// <param name="configurement"> /// The configuration for the <see cref="Builder" />. /// </param> public Builder(Configurement configurement) { _doubleProvider = configurement.DoubleProvider; _intProvider = configurement.IntProvider; _longProvider = configurement.LongProvider; _nameProvider = configurement.NameProvider; _dateTimeProvider = configurement.DateTimeProvider; _emailProvider = configurement.MailProvider; _elementProvider = configurement.ListElementPicker; _boolProvider = configurement.BoolProvider; _userNameProvider = configurement.UserNameProvider; _guidProvider = configurement.GuidProvider; _timeSpanProvider = configurement.TimeSpanProvider; _decimalProvider = configurement.DecimalProvider; _dateTimeOffsetProvider = configurement.DateTimeOffSetProvider; _floatProvider = configurement.FloatProvider; _charProvider = configurement.CharProvider; }
public static async Task InsertSeedData(ZenTimeDbContext context, IDateTimeOffsetProvider dateTimeOffsetProvider) { var service = new TimeSheetService(context); var pId1 = await service.CreatProject(new Project(TelstraPurpleProjectName)); await service.CreatProject(new Project("ACME Pty Ltd")); var aId1 = await service.CreateActivity(new Activity(AnnualLeaveActivityName)); await service.CreateActivity(new Activity("Leave - Personal")); var aId2 = await service.CreateActivity(new Activity(LGActivityName)); await service.CreateActivity(new Activity("Consulting")); await service.CreateActivity(new Activity("Pre-Sales")); await service.CreateTimeSheet( new TimeSheet(pId1, aId1, 480, dateTimeOffsetProvider.UtcNow - TimeSpan.FromDays(1), "Details 1")); await service.CreateTimeSheet( new TimeSheet(pId1, aId2, 30, dateTimeOffsetProvider.UtcNow - TimeSpan.FromHours(1), "More details ")); }
/// <summary> /// Converts <see cref="AccessTokenDto"/> to <see cref="Model.AccessToken"/>. /// </summary> /// <param name="accessToken">The access token.</param> /// <param name="dateTimeOffsetProvider">The date time offset provider.</param> /// <returns></returns> public static Model.AccessToken ToModelToken(this AccessTokenDto accessToken, IDateTimeOffsetProvider dateTimeOffsetProvider) { return(new Model.AccessToken(accessToken.Token, accessToken.ExpiresIn.ToExpiresAt(dateTimeOffsetProvider))); }
public SampledFileReporter(string directory, Encoding encoding, IReportFormatter formatter, IDateTimeOffsetProvider dateTimeOffsetProvider) : base(null, formatter) { _directory = directory; _encoding = encoding; _dateTimeOffsetProvider = dateTimeOffsetProvider; }
public IntegerTileService(ITileContext context, ITilesRepository tilesRepository, IDateTimeOffsetProvider dateTimeOffsetProvider, IEventDispatcher eventDispatcher) : base(context, tilesRepository, dateTimeOffsetProvider) { _eventDispatcher = eventDispatcher ?? throw new System.ArgumentNullException(nameof(eventDispatcher)); }
public static DateTimeOffset ToExpiresAt(this int expiresIn, IDateTimeOffsetProvider dateTimeOffsetProvider) { return(dateTimeOffsetProvider.GetUtcNow().AddSeconds(expiresIn)); }
protected Trip() { _dateTimeOffsetProvider = new DateTimeOffsetProvider(); }
public TileService(ITileContext context, ITilesRepository tilesRepository, IDateTimeOffsetProvider dateTimeOffsetProvider) { Context = context ?? throw new ArgumentNullException(nameof(context)); TilesRepository = tilesRepository ?? throw new ArgumentNullException(nameof(tilesRepository)); DateTimeOffsetProvider = dateTimeOffsetProvider ?? throw new ArgumentNullException(nameof(dateTimeOffsetProvider)); }
public FallbackProvider(IDateTimeOffsetProvider dateTimeOffsetProvider) { this.dateTimeOffsetProvider = dateTimeOffsetProvider; }
public WriteTimeInterceptor(IDateTimeOffsetProvider provider) { _provider = provider; }
public ZenTimeDbContext(DbContextOptions <ZenTimeDbContext> options, IDateTimeOffsetProvider dateTimeOffsetProvider) : base(options) { _dateTimeOffsetProvider = dateTimeOffsetProvider; }
public ZenTimeDbContext(DbContextOptions <ZenTimeDbContext> options) : base(options) { _dateTimeOffsetProvider = new DateTimeOffsetProvider(); }
public static AccessToken ToModelToken(this ProxyAccessToken proxyAccessToken, IDateTimeOffsetProvider dateTimeOffsetProvider) { return(new AccessToken(proxyAccessToken.Token, proxyAccessToken.ExpiresIn.ToExpiresAt(dateTimeOffsetProvider))); }