Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 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 When_duplicates_are_searched_by_size {
  12. static ICommand Command;
  13.  
  14. Establish context =
  15. () => { Command = new CommandLineParser().Parse(@"--size --whatif Samples\First Samples\Second".Args()); };
  16.  
  17. Because of = () => Command.Execute();
  18.  
  19. It should_find_files_of_the_same_size =
  20. () => Command.AllDuplicates().ShouldContainOnly(@"Samples\First\content-full-first.txt",
  21. @"Samples\Second\content-full-second.txt",
  22. @"Samples\First\size-first.txt",
  23. @"Samples\Second\size-second.txt");
  24. }
  25.  
  26. public class When_duplicates_are_searched_by_name {
  27. static ICommand Command;
  28.  
  29. Establish context =
  30. () => { Command = new CommandLineParser().Parse(@"--name --whatif Samples\First Samples\Second".Args()); };
  31.  
  32. Because of = () => Command.Execute();
  33.  
  34. It should_find_files_with_the_same_name =
  35. () => Command.AllDuplicates().ShouldContainOnly(@"Samples\First\name.txt",
  36. @"Samples\Second\name.txt");
  37. }
  38.  
  39. public class When_duplicates_are_searched_by_contents {
  40. static ICommand Command;
  41.  
  42. Establish context =
  43. () => { Command = new CommandLineParser().Parse(@"--content --whatif Samples\First Samples\Second".Args()); };
  44.  
  45. Because of = () => Command.Execute();
  46.  
  47. It should_find_files_with_the_same_contents =
  48. () => Command.AllDuplicates().ShouldContainOnly(@"Samples\First\content-full-first.txt",
  49. @"Samples\Second\content-full-second.txt");
  50. }
  51.  
  52. public class When_duplicates_are_searched_by_head_contents {
  53. static ICommand Command;
  54.  
  55. Establish context =
  56. () => { Command = new CommandLineParser().Parse(@"--content --first 5 --whatif Samples\First Samples\Second".Args()); };
  57.  
  58. Because of = () => Command.Execute();
  59.  
  60. It should_find_files_with_the_same_contents_in_the_first_five_bytes=
  61. () => Command.AllDuplicates().ShouldContainOnly(@"Samples\First\content-full-first.txt",
  62. @"Samples\Second\content-full-second.txt",
  63. @"Samples\First\content-head-first.txt",
  64. @"Samples\Second\content-head-second.txt");
  65. }
  66.  
  67. public class When_duplicates_are_searched_by_tail_contents {
  68. static ICommand Command;
  69.  
  70. Establish context =
  71. () => { Command = new CommandLineParser().Parse(@"--content --last 5 --whatif Samples\First Samples\Second".Args()); };
  72.  
  73. Because of = () => Command.Execute();
  74.  
  75. It should_find_files_with_the_same_contents_in_the_first_five_bytes =
  76. () => Command.AllDuplicates().ShouldContainOnly(@"Samples\First\content-full-first.txt",
  77. @"Samples\Second\content-full-second.txt",
  78. @"Samples\First\content-tail-first.txt",
  79. @"Samples\Second\content-tail-second.txt");
  80. }
  81.  
  82. public class When_duplicates_are_searched_by_head_and_tail_contents {
  83. static ICommand Command;
  84.  
  85. Establish context =
  86. () => { Command = new CommandLineParser().Parse(@"--content --first 5 --last 5 --whatif Samples\First Samples\Second".Args()); };
  87.  
  88. Because of = () => Command.Execute();
  89.  
  90. It should_find_files_with_the_same_contents_in_the_first_and_last_five_bytes =
  91. () => Command.AllDuplicates().ShouldContainOnly(@"Samples\First\content-full-first.txt",
  92. @"Samples\Second\content-full-second.txt");
  93. }
  94.  
  95. // Extension Methods
  96. internal static class Extensions {
  97. public static string[] Args(this string args) {
  98. return args.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  99. }
  100. static T As<T>(this object instance) {
  101. return (T) instance;
  102. }
  103. public static IEnumerable<string> AllDuplicates(this object instance) {
  104. return instance.As<FindDuplicatesCommand>().Duplicates.SelectMany(x => x);
  105. }
  106. }
  107. }
Add Comment
Please, Sign In to add comment