예제 #1
0
        public void GetDirectories_NullFirstReturnsEmpty()
        {
            IArgumentProvider arguments = Substitute.For <IArgumentProvider>();

            arguments.Targets.Returns(new string[] { (string)null });
            IFileService fileService = Substitute.For <IFileService>();

            arguments.GetDirectories(fileService).Should().BeEmpty();
        }
예제 #2
0
        public void GetDirectories_Splits()
        {
            IArgumentProvider arguments = Substitute.For <IArgumentProvider>();

            arguments.Targets.Returns(new string[] { "Foo", "Bar;FooBar" });
            IFileService fileService = Substitute.For <IFileService>();

            fileService.GetFullPath("").ReturnsForAnyArgs(i => (string)i[0]);
            fileService.GetAttributes("").ReturnsForAnyArgs(FileAttributes.Directory);

            arguments.GetDirectories(fileService).Should().BeEquivalentTo("Foo", "Bar", "FooBar");
        }
예제 #3
0
        public void GetDirectories_NotExistThrows()
        {
            IArgumentProvider arguments = Substitute.For <IArgumentProvider>();

            arguments.Targets.Returns(new string[] { "Foo" });
            IFileService fileService = Substitute.For <IFileService>();

            fileService.GetFullPath("").ReturnsForAnyArgs(i => (string)i[0]);
            fileService.GetAttributes("Foo").Returns(x => { throw new FileNotFoundException(); });

            Action action = () => arguments.GetDirectories(fileService);

            action.ShouldThrow <TaskArgumentException>();
        }