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(); }
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"); }
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>(); }