コード例 #1
0
        public void CategoryWithDifferentIdAreNotEqual()
        {
            var c1 = new StageCategory("category", Guid.NewGuid());
            var c2 = new StageCategory("category", Guid.NewGuid());

            Assert.That(c1, Is.Not.EqualTo(c2));
        }
コード例 #2
0
        public void CategoryWithDifferentIdAreNotEqual()
        {
            var c1 = new StageCategory("category", Guid.NewGuid());
            var c2 = new StageCategory("category", Guid.NewGuid());

            c1.Should().NotBe(c2);
        }
コード例 #3
0
        public void CategoryWithSameIdAreEqual()
        {
            var id = Guid.NewGuid();
            var c1 = new StageCategory("category", id);
            var c2 = new StageCategory("category", id);

            c1.Should().Be(c2);
        }
コード例 #4
0
        public void CategoryNameIsIrrelevant()
        {
            var id = Guid.NewGuid();
            var c1 = new StageCategory("c1", id);
            var c2 = new StageCategory("c2", id);

            c1.Should().Be(c2);
        }
コード例 #5
0
        public void CategoryWithSameIdAreEqual()
        {
            var id = Guid.NewGuid();
            var c1 = new StageCategory("category", id);
            var c2 = new StageCategory("category", id);

            Assert.That(c1, Is.EqualTo(c2));
        }
コード例 #6
0
        public void CategoryNameIsIrrelevant()
        {
            var id = Guid.NewGuid();
            var c1 = new StageCategory("c1", id);
            var c2 = new StageCategory("c2", id);

            Assert.That(c1, Is.EqualTo(c2));
        }
コード例 #7
0
        internal static void EnsureIsCompatibleWith <T>(this T component, StageCategory containingStageCategory) where T : IBaseComponent, IPersistPropertyBag
        {
            var componentCategories = component.GetStageCategories();

            if (!containingStageCategory.IsCompatibleWith(componentCategories))
            {
                throw new ArgumentException(
                          string.Format(
                              "{0} is made for any of the {1} stages and is not compatible with a {2} stage.",
                              component.Name,
                              componentCategories.Aggregate(string.Empty, (names, sc) => names + ", " + sc.Name, names => names.Substring(2)),
                              containingStageCategory.Name),
                          "component");
            }
        }
コード例 #8
0
        internal static StageCategory[] GetStageCategories <T>(this T component) where T : IBaseComponent, IPersistPropertyBag
        {
            component.EnsureIsPipelineComponent();

            var stageCategories = component.GetType().GetCustomAttributes(typeof(ComponentCategoryAttribute), false)
                                  .Cast <ComponentCategoryAttribute>()
                                  .Where(a => StageCategory.IsKnownCategoryId(a.Category))
                                  .Select(a => StageCategory.FromKnownCategoryId(a.Category))
                                  .ToArray();

            if (!stageCategories.Any())
            {
                throw new ArgumentException(
                          string.Format(
                              "{0} has not been associated with a pipeline stage category. Apply the ComponentCategoryAttribute with one of the stage categories available through {1}.",
                              component.GetType().Name,
                              typeof(CategoryTypes).FullName));
            }
            return(stageCategories);
        }
コード例 #9
0
 internal Stage(Guid categoryId, PipelinePolicy pipelinePolicy)
 {
     Category    = StageCategory.FromKnownCategoryId(categoryId);
     StagePolicy = pipelinePolicy.Stages.Cast <StagePolicy>().Single(s => new Guid(s.StageIdGuid) == Category.Id);
     Components  = new ComponentList(this);
 }
コード例 #10
0
 internal Stage(Guid categoryId)
 {
     Category   = StageCategory.FromKnownCategoryId(categoryId);
     Components = new ComponentList(this);
 }