public async Task GetMemberStats_WhenInvoked_LogsMethodInvoked() { await systemUnderTest.GetMemberStats(DateTime.MinValue, endDateMock); Received.InOrder(() => { loggingServiceMock.LogMethodInvoked(nameof(systemUnderTest.GetMemberStats)); statsDownloadApiDataStoreServiceMock.GetMembers(DateTime.MinValue, endDateMock); loggingServiceMock.LogMethodFinished(nameof(systemUnderTest.GetMemberStats)); }); }
public async Task <GetMemberStatsResponse> GetMemberStats(DateTime?startDate, DateTime?endDate) { loggingService.LogMethodInvoked(); IList <ApiError> errors = new List <ApiError>(); bool isNotPreparedToRun = await IsNotPreparedToGetMemberStats(startDate, endDate, errors); if (isNotPreparedToRun) { loggingService.LogMethodFinished(); return(new GetMemberStatsResponse(errors)); } DateTime startDateTime = startDate.GetValueOrDefault(); DateTime endDateTime = endDate.GetValueOrDefault(); if (startDateTime.Date == startDateTime && startDateTime.Date == endDateTime) { startDateTime = startDateTime.Date.AddHours(12); endDateTime = endDateTime.Date.AddHours(36); } IList <Member> members = await statsDownloadApiDataStoreService.GetMembers(startDateTime, endDateTime); var memberStatsResponse = new GetMemberStatsResponse(members); loggingService.LogMethodFinished(); return(memberStatsResponse); }
public Task <Member[]> GetMembers(DateTime startDate, DateTime endDate) { return(GetOrAdd(async() => await innerService.GetMembers(startDate, endDate), DateTimeOffset.Now.AddHours(cacheDurationInHours), $"{startDate}-{endDate}")); }