Пример #1
0
            public void Add_a_file_with_no_dependencies()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();

                // Act
                tracker.Add("some template", null);

                // Assert
                Assert.That(tracker.DependentFiles, Is.Empty);
                Assert.That(tracker.FileDependencies, Is.Empty);
            }
Пример #2
0
            public void Add_a_file_with_dependencies()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();

                // Act
                tracker.Add("some post", "layout 1");

                // Assert
                Assert.That(tracker.FileDependencies["some post"],
                    Is.EquivalentTo(new HashSet<string> {"layout 1"}));

                Assert.That(tracker.DependentFiles.Keys, Contains.Item("layout 1"));
                Assert.That(tracker.DependentFiles["layout 1"], Contains.Item("some post"));
            }
Пример #3
0
            public void Remove_a_file_with_a_shared_dependency()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();

                tracker.FileDependencies.Add("some post", new HashSet<string> {"layout 1"});
                tracker.FileDependencies.Add("another post", new HashSet<string> {"layout 1"});
                tracker.DependentFiles.Add("layout 1", new HashSet<string>
                    {
                        "some post",
                        "another post"
                    });

                // Act
                tracker.Remove("some post");

                // Assert
                Assert.That(tracker.FileDependencies.Keys, Has.None.Contains("some post"));
                Assert.That(tracker.DependentFiles["layout 1"], Has.No.Contains("some post"));
            }
Пример #4
0
            public void Remove_an_untracked_file()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();

                // Act
                tracker.Remove("untracked");

                // Assert
            }
Пример #5
0
            public void Remove_a_file_with_an_unique_dependency()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();
                tracker.FileDependencies.Add("some post", new HashSet<string> {"layout 1"});
                tracker.DependentFiles.Add("layout 1", new HashSet<string>{"some post"});

                // Act
                tracker.Remove("some post");

                // Assert
                Assert.That(tracker.FileDependencies, Is.Empty);
                Assert.That(tracker.DependentFiles, Is.Empty);
            }
Пример #6
0
            public void Find_files()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();
                tracker.DependentFiles.Add("layout 1", new HashSet<string>
                    {
                        "some post",
                        "another post"
                    });

                // Act
                var files = tracker.FindDependentFiles("layout 1");

                // Assert
                Assert.That(files, Is.EquivalentTo(new List<string>
                    {
                        "some post",
                        "another post"
                    }));
            }
Пример #7
0
            public void Empty_result()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();

                // Act
                var files = tracker.FindDependentFiles("unused layout");

                // Assert
                Assert.That(files, Is.Empty);
            }
Пример #8
0
            public void With_zero_dependencies()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();

                // Act
                var dependency = tracker.FindFileDependencies("some post");

                // Assert
                Assert.That(dependency, Is.Null);
            }
Пример #9
0
            public void With_one_dependency()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();
                tracker.FileDependencies.Add("some post", new HashSet<string> {"layout 1"});

                // Act
                var dependency = tracker.FindFileDependencies("some post");

                // Assert
                Assert.That(dependency, Is.EquivalentTo(new HashSet<string> {"layout 1"}));
            }
Пример #10
0
            public void Find_recursively()
            {
                // Arrange
                var tracker = new TestableDependencyTracker();
                tracker.DependentFiles.Add("base layout", new HashSet<string> {"layout 1", "layout 2"});
                tracker.DependentFiles.Add("layout 1", new HashSet<string> {"A", "B"});
                tracker.DependentFiles.Add("layout 2", new HashSet<string> {"C"});

                var expectedOrder = new string[]
                    {
                        "layout 1",
                        "layout 2",
                        "A",
                        "B",
                        "C"
                    };

                // Act
                var files = tracker.FindAllDependentFiles("base layout");

                // Assert
                Assert.That(files, Is.EquivalentTo(expectedOrder));
                for (int i = 0; i < expectedOrder.Length; i++)
                    Assert.That(files[i], Is.EqualTo(expectedOrder[i]));
            }