Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void Constructor_ShouldSetPropertiesAndCallConfig()
        {
            EFTogglWorkspace efTogglWorkspace = new EFTogglWorkspace(_context.Object, _config.Object, _iAPIMethod.Object);

            _config.Verify(x => x.GetKey(It.IsAny <string>()), Times.Once);
            Assert.IsNotNull(efTogglWorkspace.ApiKey);
            Assert.IsNotNull(efTogglWorkspace.Entries);
        }
Ejemplo n.º 3
0
        public void CacheEntries_ShouldCallGetWorkspacesAndSave()
        {
            EFTogglWorkspace efTogglWorkspace = new EFTogglWorkspace(_context.Object, _config.Object, _iAPIMethod.Object);

            efTogglWorkspace.CacheEntries();

            _iAPIMethod.Verify(x => x.GetWorkspaces(), Times.Once);
            _context.Verify(x => x.SaveChanges(), Times.Once);
        }