static void Main(string[] args) { Blockbuster blockbuster = new Blockbuster(); blockbuster.Movies.Add(new DVD("Test Movie 1", Genre.Drama, 100)); blockbuster.Movies.Add(new DVD("Test Movie 2", Genre.Comedy, 110)); blockbuster.Movies.Add(new DVD("Test Movie 3", Genre.Horror, 130)); blockbuster.Movies.Add(new VHS("Test Movie 4", Genre.Romance, 140)); blockbuster.Movies.Add(new VHS("Test Movie 5", Genre.Action, 150)); blockbuster.Movies.Add(new VHS("Test Movie 6", Genre.Romance, 160)); foreach (Movie movie in blockbuster.Movies) { movie.Scenes.Add("Scene 1"); movie.Scenes.Add("Scene 2"); movie.Scenes.Add("Scene 3"); movie.Scenes.Add("Scene 4"); } //blockbuster.Movies[1].Play(); //blockbuster.Movies[4].Play(); //blockbuster.Movies[1].PlayWholeMovie(); //blockbuster.Movies[4].PlayWholeMovie(); //blockbuster.CheckOut(blockbuster.Movies); //blockbuster.PrintMovies(blockbuster.Movies); //blockbuster.CheckOut(blockbuster.Movies); }
static void Main(string[] args) { Blockbuster store = new Blockbuster(); string another = "y"; Console.WriteLine("Welcom to Blockbuster!"); do { try { Movie selectedMovie = store.CheckOut(); Console.WriteLine("\nYou selected: "); selectedMovie.PrintInfo(); Console.Write("\nDo you want to play a scene from this movie (s), play the whole movie (p), select a new movie (m), or exit (x). "); string playOption = Console.ReadLine().ToLower().Trim(); switch (playOption) { case "s": selectedMovie.Play(); break; case "p": selectedMovie.PlayWholeMovie(); break; case "m": another = "y"; break; case "x": another = "n"; break; } if (selectedMovie is VHS vhs) { Console.Write("\nDo you want to rewind? (y/n) "); string backToStart = Console.ReadLine().ToLower().Trim(); if (backToStart == "y") { vhs.Rewind(); } } } catch { Console.WriteLine("Something went wrong. Please try again."); another = "y"; } }while (another == "y"); Console.WriteLine("Goodbye!"); }
public void DeletesCompleteDirectory() { TestFileGenerator.Generate(_testFilePath, 3, 2); DirectoryInfo directory = new DirectoryInfo(_testFilePath); Assert.That(directory.GetFiles().Count<FileInfo>() > 0,"no testfiles present"); Blockbuster service = new Blockbuster(); service.CleanUp(_testFilePath); Assert.That(directory.GetFiles().Count<FileInfo>() == 0); }
public void DeletesOnlyFiles() { TestFileGenerator.Generate(_testFilePath, 3, 2); DirectoryInfo directory = new DirectoryInfo(_testFilePath); Assert.That(directory.GetFiles().Count<FileInfo>() > 0, "no testfiles present"); AbstractCommand[] commands = { new FilesOnly() }; Blockbuster service = new Blockbuster(); service.CleanUp(_testFilePath, commands); Assert.That(directory.GetFiles().Count<FileInfo>() == 0); }
public void DeletesFilesOnly() { AssertEmptyTestDirectory(); TestFileGenerator.Generate(_testFilePath, 3, 2); var directory = new DirectoryInfo(_testFilePath); Assert.That(directory.GetFiles().Count<FileInfo>() > 0,"no testfiles present"); var service = new Blockbuster(); var dynamicConfiguration = MockRepository.GenerateStub<IDynamicConfiguration>(); dynamicConfiguration.Stub(x => x.GetCommandConfigurations()).Return(new[] {string.Format("CommandName='FilesOnly'; Directory='{0}'", _testFilePath)}); service.CleanUp(dynamicConfiguration, false); Assert.That(directory.GetFiles().Count<FileInfo>() == 0); }
static void Main(string[] args) { Console.WriteLine("Welcome to GC Blockbuster"); Blockbuster bb = new Blockbuster(); bool bContinue = true; while (bContinue) { Movie movieOpt = bb.Checkout(); Console.WriteLine("\nDo you want to watch the movie? y/n"); if (Console.ReadLine().ToLower()[0] == 'y') { Console.WriteLine("Do you want to watch the whole movie? y/n"); if (Console.ReadLine().ToLower()[0] == 'y') { movieOpt.PlayWholeMovie(); } else { if (movieOpt.GetType() == typeof(DVD)) { Console.WriteLine(); movieOpt.Play(); } else { VHS vhsObj = (VHS)movieOpt; vhsObj.Play(); } } } Console.WriteLine("Do you want to watch another movie? y/n"); if (Console.ReadLine().ToLower()[0] != 'y') { bContinue = false; Console.WriteLine("Bye"); } else { Console.Clear(); } } }
public void DeletesFilesInBetweenSpecificTimeRangeButKeepsOthers() { AssertEmptyTestDirectory(); var txtFileInfo = new FileInfo(_testFilePath + "\\test.txt"); using (txtFileInfo.Create()) { } var dateTimeTimeRangeStart = DateTime.Now; Thread.Sleep(1000); var txtFileInfo2 = new FileInfo(_testFilePath + "\\test2.txt"); using (txtFileInfo2.Create()) { } Thread.Sleep(1000); var dateTimeTimeRangeStop = DateTime.Now; var txtFileInfo3 = new FileInfo(_testFilePath + "\\test3.txt"); using (txtFileInfo3.Create()) { } var directory = new DirectoryInfo(_testFilePath); Assert.That(directory.GetFiles().Count<FileInfo>() > 0, "no testfiles present"); var service = new Blockbuster(); var dynamicConfiguration = MockRepository.GenerateStub<IDynamicConfiguration>(); Thread.Sleep(1000); //Sleep for one second to force files to be older dynamicConfiguration.Stub(x => x.GetCommandConfigurations()).Return(new[] { string.Format("CommandName='FileExtension'; FileExtension='txt'; Directory='{0}'", _testFilePath), string.Format("CommandName='IsNewer'; IsNewer='{0}'; Directory='{1}'", dateTimeTimeRangeStart, _testFilePath), string.Format("CommandName='IsOlder'; IsOlder='{0}'; Directory='{1}'", dateTimeTimeRangeStop, _testFilePath) }); service.CleanUp(dynamicConfiguration, true); Assert.That(txtFileInfo.Exists); Assert.That(!txtFileInfo2.Exists); Assert.That(txtFileInfo3.Exists); }
public void DeletesTxtFilesButKeepsBakFiles() { AssertEmptyTestDirectory(); var txtFileInfo = new FileInfo(_testFilePath + "\\test.txt"); using (txtFileInfo.Create()) { } var bakFileInfo = new FileInfo(_testFilePath + "\\test.bak"); using (bakFileInfo.Create()) { } var directory = new DirectoryInfo(_testFilePath); Assert.That(directory.GetFiles().Count<FileInfo>() > 0, "no testfiles present"); var service = new Blockbuster(); var dynamicConfiguration = MockRepository.GenerateStub<IDynamicConfiguration>(); dynamicConfiguration.Stub(x => x.GetCommandConfigurations()).Return(new[] { string.Format("CommandName='FileExtension'; FileExtension='txt'; Directory='{0}'", _testFilePath) }); service.CleanUp(dynamicConfiguration, true); Assert.That(!txtFileInfo.Exists); Assert.That(bakFileInfo.Exists); }
private void AssertEmptyTestDirectory() { var service = new Blockbuster(); service.CleanUp(_testFilePath); var directoryInfo = new DirectoryInfo(_testFilePath); Assert.AreEqual(0, directoryInfo.GetFiles().Count()); Assert.AreEqual(0, directoryInfo.GetDirectories().Count()); }
public void DeletesTxtFilesOlderDateButKeepsBakFilesWithSameDate() { AssertEmptyTestDirectory(); var txtFileInfo = new FileInfo(_testFilePath + "\\test.txt"); using (txtFileInfo.Create()) { } var bakFileInfo = new FileInfo(_testFilePath + "\\test.bak"); using (bakFileInfo.Create()) { } var directory = new DirectoryInfo(_testFilePath); Assert.That(directory.GetFiles().Count<FileInfo>() > 0, "no testfiles present"); var service = new Blockbuster(); var dynamicConfiguration = MockRepository.GenerateStub<IDynamicConfiguration>(); Thread.Sleep(1000); //Sleep for one second to force files to be older dynamicConfiguration.Stub(x => x.GetCommandConfigurations()).Return(new[] { string.Format("CommandName='FileExtension'; FileExtension='txt'; Directory='{0}'", _testFilePath), string.Format("CommandName='IsOlder'; IsOlder='{0}'; Directory='{1}'", DateTime.Now, _testFilePath) }); service.CleanUp(dynamicConfiguration, true); Assert.That(!txtFileInfo.Exists); Assert.That(bakFileInfo.Exists); }