public void TestCreateFile() { //path var path = "c:\\test\\myfile.avi"; var container = CreateContainer(c => { c.RegisterFake<IFindFileTypeStrategy>() .FindType(Arg.Any<string>()) .Returns(FileType.Video); }); var processor = container.Resolve<ICommandProcessor>(); var folder = new FolderNode(processor) { FullPath = "c:\\test" }; processor.Process(new CreateFileCommand() { Folder = folder, Path = path }); Assert.IsNotNull(folder.Content); Assert.AreEqual(1, folder.Content.Count); }
public void TestGetPlayablesAffectedByFolder() { var folderPath = "c:\\test"; var file = new FileNode() { FullPath = folderPath + "\\test.mp3" }; var container = CreateContainer(c => { c.RegisterFake<IQueryHandler<GetPlayableFilesQuery, IQueryable<PlayableFile>>>() .Handle(Arg.Any<GetPlayableFilesQuery>()) .Returns(new[] { new PlayableFile() { File = file } }.AsQueryable()); c.RegisterFake<IQueryHandler<GetPlayerFoldersQuery, IQueryable<FolderNode>>>() .Handle(Arg.Any<GetPlayerFoldersQuery>()) .Returns(new[] { new FolderNode(null) { FullPath = folderPath }.RandomizeTheRest() }.AsQueryable()); }); var commandProcessor = container.Resolve<ICommandProcessor>(); var folder = new FolderNode(commandProcessor) { FullPath = folderPath }; folder.AddFile(file); var queryProcessor = container.Resolve<IQueryProcessor>(); var center = container.Resolve<IDataCenter>(); var playables = queryProcessor.Process(new GetPlayablesAffectedByFolderQuery() { Folder = folder }); Assert.IsNotNull(playables); Assert.AreEqual(1, playables.Count()); }
public void TestCreatePlayer() { var filename = "001 - Chana de Souza Mason.png"; var playername = "Chana de Souza Mason"; var number = 1; var file = new FileNode() { Name = filename, NameWithoutExtension = "001 - Chana de Souza Mason", FullPath = Path.Combine("stuff", filename) }; var statFolder = new FolderNode(null); var container = CreateContainer(c => { c.RegisterFake<IQueryHandler<GetPlayerFoldersQuery, IQueryable<FolderNode>>>() .Handle(Arg.Any<GetPlayerFoldersQuery>()) .Returns(new[] { new FolderNode(null) { Content = new List<FileNode>() { file } } }.AsQueryable()); }); var processor = container.Resolve<ICommandProcessor>(); processor.Process(new CreatePlayerCommand() { File = file, Folder = statFolder }); var datacenter = container.Resolve<IDataCenter>(); Assert.AreEqual(playername, datacenter.Players[0].Name); Assert.AreEqual(number, datacenter.Players[0].Number); Assert.AreEqual(file, datacenter.Players[0].Content.ToList()[0]); Assert.IsFalse(datacenter.Players[0].Trainer); }