private void CacheToggl() { WriteTimeLog("--CacheToggl", "Starting"); ITogglWorkspace efToggl = new EFTogglWorkspace(); efToggl.CacheEntries(); ITogglTimeEntries efTimeEntries = new EFTogglTimeEntries(); string workspace = _configuration.GetKey("APISources:Toggl:Workspace"); string fromDateDaysString = _configuration.GetKey("APISources:Toggl:FromDateDays"); int?fromDateDays = null; if (!String.IsNullOrEmpty(fromDateDaysString)) { try { fromDateDays = int.Parse(fromDateDaysString); } catch (Exception e) { throw new InvalidCastException( "Unable to convert the integer (intended) value in the APISources:Toggl:FromDateDays setting in the appSettings"); } } efTimeEntries.CacheEntries(workspace, fromDateDays); }
public void CacheEntries_WithWorkspaceAndDatetime_ShouldCallGetAndSave(string workspaceName, string fromDateString) { EFTogglTimeEntries efTogglTimeEntries = new EFTogglTimeEntries(_context.Object, _config.Object, _iAPIMethod.Object); DateTime?fromDate = null; if (!string.IsNullOrEmpty(fromDateString)) { fromDate = DateTime.Parse(fromDateString); } efTogglTimeEntries.CacheEntries(workspaceName, fromDate); _iAPIMethod.Verify(x => x.GetTimeEntries(workspaceName, fromDate, null), Times.Once); _context.Verify(x => x.SaveChanges(), Times.Once); }