コード例 #1
0
        protected override void Check()
        {
            var components = Enumerable.Range(0, componentCount).Select(i => new C()).ToArray();
            var model      = TestModel.InitializeModel(components);

            // heuristics are called appropriately
            var counter = new CountingHeuristic();

            Heuristics = new[] { counter };

            var result = Dcca(model, false);

            result.IsComplete.ShouldBe(true);
            result.Exceptions.ShouldBeEmpty();
            result.MinimalCriticalSets.ShouldBeEmpty();
            result.CheckedSets.Count.ShouldBe(1 << model.Faults.Length);
            counter.setCounter.ShouldBe((ulong)result.CheckedSets.Count);
            counter.cardinalityCounter.ShouldBe(model.Faults.Length + 1);

            // redundancy heuristic works properly
            Heuristics = new[] { new MinimalRedundancyHeuristic(
                                     model.Faults,
                                     components.Select(c => c.F1),
                                     components.Select(c => c.F2)
                                     ) };

            result = Dcca(model, false);
            result.IsComplete.ShouldBe(true);
            result.Exceptions.ShouldBeEmpty();
            result.MinimalCriticalSets.ShouldBeEmpty();
            result.CheckedSets.Count.ShouldBe(47);
            ((ulong)result.CheckedSets.Count).ShouldBeLessThan(counter.setCounter);

            // subsumption heuristic is effective
            Heuristics = new[] { new SubsumptionHeuristic(model.Faults) };

            foreach (var c in components)
            {
                c.F1.Subsumes(c.F2);
            }

            result = Dcca(model, false);
            result.IsComplete.ShouldBe(true);
            result.Exceptions.ShouldBeEmpty();
            result.MinimalCriticalSets.ShouldBeEmpty();
            result.CheckedSets.Count.ShouldBe(81);
            ((ulong)result.CheckedSets.Count).ShouldBeLessThan(counter.setCounter);             // heuristic has effect

            // heuristics are called appropriately when combined
            counter    = new CountingHeuristic();
            Heuristics = new IFaultSetHeuristic[] { counter, new SubsumptionHeuristic(model.Faults) };

            result = Dcca(model, false);
            result.IsComplete.ShouldBe(true);
            result.Exceptions.ShouldBeEmpty();
            result.MinimalCriticalSets.ShouldBeEmpty();
            counter.cardinalityCounter.ShouldBe(model.Faults.Length + 1);
            result.CheckedSets.Count.ShouldBeLessThan(1 << model.Faults.Length);
            counter.setCounter.ShouldBeGreaterThanOrEqualTo((ulong)result.CheckedSets.Count);
        }
コード例 #2
0
		protected override void Check()
		{
			var components = Enumerable.Range(0, componentCount).Select(i => new C()).ToArray();
			var model = TestModel.InitializeModel(components);

			// heuristics are called appropriately
			var counter = new CountingHeuristic();
			Heuristics = new[] { counter };

			var result = Dcca(model, false);
			result.IsComplete.ShouldBe(true);
			result.Exceptions.ShouldBeEmpty();
			result.MinimalCriticalSets.ShouldBeEmpty();
			result.CheckedSets.Count.ShouldBe(1 << model.Faults.Length);
			counter.setCounter.ShouldBe((ulong)result.CheckedSets.Count);
			counter.cardinalityCounter.ShouldBe(model.Faults.Length + 1);

			// redundancy heuristic works properly
			Heuristics = new[] { new MinimalRedundancyHeuristic(
				model,
					components.Select(c => c.F1),
					components.Select(c => c.F2)
				)
			};

			result = Dcca(model, false);
			result.IsComplete.ShouldBe(true);
			result.Exceptions.ShouldBeEmpty();
			result.MinimalCriticalSets.ShouldBeEmpty();
			result.CheckedSets.Count.ShouldBe(47);
			((ulong)result.CheckedSets.Count).ShouldBeLessThan(counter.setCounter);

			// subsumption heuristic is effective
			Heuristics = new[] { new SubsumptionHeuristic(model) };

			foreach (var c in components)
				c.F1.Subsumes(c.F2);

			result = Dcca(model, false);
			result.IsComplete.ShouldBe(true);
			result.Exceptions.ShouldBeEmpty();
			result.MinimalCriticalSets.ShouldBeEmpty();
			result.CheckedSets.Count.ShouldBe(81);
			((ulong)result.CheckedSets.Count).ShouldBeLessThan(counter.setCounter); // heuristic has effect

			// heuristics are called appropriately when combined
			counter = new CountingHeuristic();
			Heuristics = new IFaultSetHeuristic[] { counter, new SubsumptionHeuristic(model) };

			result = Dcca(model, false);
			result.IsComplete.ShouldBe(true);
			result.Exceptions.ShouldBeEmpty();
			result.MinimalCriticalSets.ShouldBeEmpty();
			counter.cardinalityCounter.ShouldBe(model.Faults.Length + 1);
			result.CheckedSets.Count.ShouldBeLessThan(1 << model.Faults.Length);
			counter.setCounter.ShouldBeGreaterThanOrEqualTo((ulong)result.CheckedSets.Count);
		}