Guest User

Untitled

a guest
Jul 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. using DuplicateFinder.Core.Commands;
  6.  
  7. using Machine.Specifications;
  8.  
  9. namespace DuplicateFinder.Core.Integration.Tests {
  10.  
  11. public class FindingDuplicates {
  12.  
  13. It can_find_files_with_the_same_size =()=> {
  14. RunCommand(@"--size --whatif Samples\First Samples\Second");
  15. AllDuplicates.ShouldContainOnly(@"Samples\First\content-full-first.txt",
  16. @"Samples\Second\content-full-second.txt",
  17. @"Samples\First\size-first.txt",
  18. @"Samples\Second\size-second.txt");
  19. };
  20.  
  21. It can_find_files_with_the_same_name =()=> {
  22. RunCommand(@"--name --whatif Samples\First Samples\Second");
  23. AllDuplicates.ShouldContainOnly(@"Samples\First\name.txt", @"Samples\Second\name.txt");
  24. };
  25.  
  26. It can_find_files_with_the_same_contents =()=> {
  27. RunCommand(@"--content --whatif Samples\First Samples\Second");
  28. AllDuplicates.ShouldContainOnly(@"Samples\First\content-full-first.txt", @"Samples\Second\content-full-second.txt");
  29. };
  30.  
  31. It can_find_files_with_the_same_head_content =()=> {
  32. RunCommand(@"--content --first 5 --whatif Samples\First Samples\Second");
  33. AllDuplicates.ShouldContainOnly(@"Samples\First\content-full-first.txt",
  34. @"Samples\Second\content-full-second.txt",
  35. @"Samples\First\content-head-first.txt",
  36. @"Samples\Second\content-head-second.txt");
  37. };
  38.  
  39. It can_find_files_with_the_same_tail_content =()=> {
  40. RunCommand(@"--content --last 5 --whatif Samples\First Samples\Second");
  41. AllDuplicates.ShouldContainOnly(@"Samples\First\content-full-first.txt",
  42. @"Samples\Second\content-full-second.txt",
  43. @"Samples\First\content-tail-first.txt",
  44. @"Samples\Second\content-tail-second.txt");
  45. };
  46.  
  47. It can_find_files_with_the_same_head_and_tail_content =()=> {
  48. RunCommand(@"--content --first 5 --last 5 --whatif Samples\First Samples\Second");
  49. AllDuplicates.ShouldContainOnly(@"Samples\First\content-full-first.txt", @"Samples\Second\content-full-second.txt");
  50. }
  51.  
  52. // Helpers
  53. static ICommand Command;
  54. static ICommand RunCommand(string command) {
  55. var args = command.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  56. Command = new CommandLineParser().Parse(args);
  57. Command.Execute();
  58. return Command;
  59. }
  60. static IEnumerable<string> AllDuplicates {
  61. get { return (Command as FindDuplicatesCommand).Duplicates.SelectMany(x => x); }
  62. }
  63. }
  64. }
Add Comment
Please, Sign In to add comment