public void TestGetCached()
        {
            var catalog = CatalogTest.CreateTestCatalog();

            catalog.Normalize();

            _sut.GetCached().Should().BeNull();
            TestGetOnline();
            _sut.GetCached().Should().Be(catalog);
        }
Пример #2
0
        public static Catalog GetCachedSafe([NotNull] this ICatalogManager manager)
        {
            #region Sanity checks
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }
            #endregion

            try
            {
                return(manager.GetCached() ?? new Catalog());
            }
            #region Error handling
            catch (IOException ex)
            {
                Log.Warn(ex.Message);
                return(new Catalog());
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.Warn(ex.Message);
                return(new Catalog());
            }
            catch (InvalidDataException ex)
            {
                Log.Warn(ex.Message);
                return(new Catalog());
            }
            #endregion
        }
    public static Catalog GetCachedSafe(this ICatalogManager manager)
    {
        #region Sanity checks
        if (manager == null)
        {
            throw new ArgumentNullException(nameof(manager));
        }
        #endregion

        try
        {
            return(manager.GetCached() ?? new());
        }
        #region Error handling
        catch (Exception ex) when(ex is IOException or UnauthorizedAccessException or InvalidDataException)
        {
            Log.Warn(Resources.ErrorLoadingCatalog, ex);
            return(new());
        }
        #endregion
    }