Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CostAggregationServiceTests"/> class.
 /// </summary>
 /// <param name="fixture"><see cref="CostAggregationServiceFixture"/> instance.</param>
 public CostAggregationServiceTests(CostAggregationServiceFixture fixture)
 {
     this._settings   = fixture.Settings;
     this._dbContext  = fixture.DbContext;
     this._auth       = fixture.Authentication;
     this._billing    = fixture.Billing;
     this._httpClient = fixture.HttpClient;
     this._service    = fixture.Service;
 }
        private static async Task <int> ProcessAggregatorAsync(ICostAggregationService service, TraceWriter log, ArgumentOptions options = null, int?monthsBack = null)
        {
            var dateStart = options != null?BillingHelper.GetStartDate(options) : BillingHelper.GetStartDateOfMonth(monthsBack.Value);

            var dateEnd = options != null?BillingHelper.GetEndDate(options) : BillingHelper.GetEndDateOfMonth(monthsBack.Value);

            log.Info($"Usage from {dateStart.ToLocalTime():yyyy-MM-dd HH:mm:ss} to {dateEnd.ToLocalTime():yyyy-MM-dd HH:mm:ss}:");

            var result = await service.ProcessAsync(dateStart, dateEnd).ConfigureAwait(false);

            return(result);
        }
        private static async Task <int> ProcessAsync(ICostAggregationService service, ArgumentOptions options = null, int?monthsBack = null)
        {
            var dateStart = options != null?BillingHelper.GetStartDate(options) : BillingHelper.GetStartDateOfMonth(monthsBack.Value);

            var dateEnd = options != null?BillingHelper.GetEndDate(options) : BillingHelper.GetEndDateOfMonth(monthsBack.Value);

            Console.WriteLine($"Usage from {dateStart.ToLocalTime():yyyy-MM-dd HH:mm:ss} to {dateEnd.ToLocalTime():yyyy-MM-dd HH:mm:ss}:");
            Console.WriteLine();

            var watch = Stopwatch.StartNew();

            var result = await service.ProcessAsync(dateStart, dateEnd).ConfigureAwait(false);

            watch.Stop();

            Console.WriteLine();
            Console.WriteLine($"Execution time: {watch.ElapsedMilliseconds} ms");

            return(result);
        }