示例#1
0
        public PageComposer(INavigationService navigator)
        {
            if (navigator == null)
            {
                throw new ArgumentNullException(nameof(navigator));
            }

            // initialisation des dépendances avec un cycle de vie de singleton
            this.navigator = navigator;

            fileService = new WindowsFileService();

            articlePictureSettings = CreateArticlePictureSettings();

            articlePictureNameFormatter = new ArticlePictureNameFormatter(
                articlePictureSettings);

            pictureLocator = new ArticlePictureLocator(
                fileService,
                articlePictureNameFormatter,
                articlePictureSettings);

            passwordHashGenerator = new PasswordHashGenerator();
            passwordHashComparer  = new PasswordHashComparer();

            messageBoxDialogService = new MessageBoxDialogService();

            CreatePictureFolderIfDoesNotExist();
            CreateDatabaseIfDoesNotExist();
        }
        public void Constructor_NullNameFormaterPassed_Throws()
        {
            IArticlePictureNameFormatter nullFormater = null;

            var exception = Assert.Catch <ArgumentNullException>(
                () => new ArticlePicturePathFormatter(
                    new ArticlePictureSettings("", "", ""),
                    nullFormater));
        }
        private ArticlePictureLocator CreateArticlePictureLocator(
            IFileService fileService,
            IArticlePictureNameFormatter fileNameFormater)
        {
            ArticlePictureSettings pictureSettings = CreatePictureSettings();
            var locator = new ArticlePictureLocator(fileService, fileNameFormater, pictureSettings);

            return(locator);
        }
        public ArticlePicturePathFormatter(
            ArticlePictureSettings settings,
            IArticlePictureNameFormatter formatter)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (formatter == null)
            {
                throw new ArgumentNullException(nameof(formatter));
            }

            this.settings  = settings;
            this.formatter = formatter;
        }
        public ArticlePictureLocator(
            IFileService fileService,
            IArticlePictureNameFormatter nameFormatter,
            ArticlePictureSettings settings)
        {
            if (fileService == null)
            {
                throw new ArgumentNullException(nameof(fileService));
            }
            if (nameFormatter == null)
            {
                throw new ArgumentNullException(nameof(nameFormatter));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this.fileService   = fileService;
            this.nameFormatter = nameFormatter;
            this.settings      = settings;

            availableArticlePictureCache = new List <string>();
        }