Exemple #1
0
        public void SortDirectory_ImagesExist_OpensImages()
        {
            // Arrange
            var directory = "C:\\images";
            var files     = new string[] { "image1.jpg", "image2.jpg" };
            var images    = new IImage[] { Fake.Image(), Fake.Image() };

            var options    = Fake.Options();
            var rotator    = Fake.ImageRotator();
            var factory    = Fake.ImageFactory(images);
            var fileSystem = Fake.FileSystem(files);

            var sorter = new DirectorySorter(rotator, factory, fileSystem);

            // Act
            sorter.SortDirectory(directory, options);

            // Assert
            factory.Received(1).OpenImage(Arg.Is(files[0]));
            factory.Received(1).OpenImage(Arg.Is(files[1]));
        }
Exemple #2
0
        public void SortDirectory_DirectoryDoesNotExist_ThrowsDirectoryNotFoundException()
        {
            // Arrange
            var dir    = "C:\\Images";
            var sorter = new DirectorySorter(Fake.ImageRotator(), Fake.ImageFactory(), Fake.FileSystem(null));

            // Act, Assert
            Assert.Throws <DirectoryNotFoundException>(() => sorter.SortDirectory(dir, Fake.Options()));
        }
Exemple #3
0
        public void SortDirectory_NoDirectoryProvided_ThrowsArgumentException([Values("", " ", null)] string dir)
        {
            // Arrange
            var sorter = new DirectorySorter(Fake.ImageRotator(), Fake.ImageFactory(), Fake.FileSystem(Enumerable.Empty <string>()));

            // Act, Assert
            Assert.Throws <ArgumentException>(() => sorter.SortDirectory(dir, Fake.Options()));
        }