示例#1
0
        public void Basic_EmptyTypes_AnyOrder()
        {
            // Arrange

            var enricher1 = new Enricher1();
            var enricher2 = new Enricher2();
            var enricher3 = new Enricher3();

            // Act

            var result = EnricherSorter.Default.Sort(new IEnricher[] { enricher1, enricher2, enricher3 }).ToList();

            // Assert

            Assert.Equal(3, result.Count);
        }
示例#2
0
        public void ExecuteBefore_CircularReference_InvalidOperationException()
        {
            // Arrange

            var enricher1 = new Enricher1 {
                ExecuteBefore = new[] { typeof(Enricher2) }
            };
            var enricher2 = new Enricher2 {
                ExecuteBefore = new[] { typeof(Enricher1) }
            };
            var enricher3 = new Enricher3();

            // Act/Assert


            Assert.Throws <InvalidOperationException>(
                () => EnricherSorter.Default.Sort(new IEnricher[] { enricher1, enricher2, enricher3 }).ToList());
        }
示例#3
0
        public void ExecuteAfter_TwoDependsOnBoth_TwoIsLast()
        {
            // Arrange

            var enricher1 = new Enricher1();
            var enricher2 = new Enricher2 {
                ExecuteAfter = new[] { typeof(Enricher1), typeof(Enricher3) }
            };
            var enricher3 = new Enricher3();

            // Act

            var result = EnricherSorter.Default.Sort(new IEnricher[] { enricher1, enricher2, enricher3 }).ToList();

            // Assert

            Assert.Equal(3, result.Count);

            var index2 = result.IndexOf(enricher2);

            Assert.Equal(2, index2);
        }
示例#4
0
        public void ExecuteAfter_OneDependsOnThree_ThreeBeforeOne()
        {
            // Arrange

            var enricher1 = new Enricher1 {
                ExecuteAfter = new[] { typeof(Enricher3) }
            };
            var enricher2 = new Enricher2();
            var enricher3 = new Enricher3();

            // Act

            var result = EnricherSorter.Default.Sort(new IEnricher[] { enricher1, enricher2, enricher3 }).ToList();

            // Assert

            Assert.Equal(3, result.Count);

            var index1 = result.IndexOf(enricher1);
            var index3 = result.IndexOf(enricher3);

            Assert.True(index3 < index1);
        }
示例#5
0
        public void Mixed_Chained_Sorted()
        {
            // Arrange

            var enricher1 = new Enricher1 {
                ExecuteAfter = new[] { typeof(Enricher2) }
            };
            var enricher2 = new Enricher2();
            var enricher3 = new Enricher3 {
                ExecuteBefore = new[] { typeof(Enricher2) }
            };

            // Act

            var result = EnricherSorter.Default.Sort(new IEnricher[] { enricher1, enricher2, enricher3 }).ToList();

            // Assert

            Assert.Equal(3, result.Count);

            Assert.Equal(enricher1, result[2]);
            Assert.Equal(enricher2, result[1]);
            Assert.Equal(enricher3, result[0]);
        }