public void PhaseTest() { CompositionContainer container = ContainerFactory.Create(); CompositionBatch batch = new CompositionBatch(); var part = new OrderingTestComposablePart(); part.AddImport("Import1", ImportCardinality.ExactlyOne, true, false); part.AddExport("Export1", 1); part.CallOrder.Enqueue("Import:Import1"); part.CallOrder.Enqueue("OnComposed"); batch.AddExportedValue("Import1", 20); batch.AddPart(part); container.Compose(batch); // Export shouldn't be called until it is pulled on by someone. var export = container.GetExport<object>("Export1"); part.CallOrder.Enqueue("Export:Export1"); Assert.AreEqual(1, export.Value); Assert.IsTrue(part.CallOrder.Count == 0); }
public void PhaseTest() { CompositionContainer container = ContainerFactory.Create(); CompositionBatch batch = new CompositionBatch(); var part = new OrderingTestComposablePart(); part.AddImport("Import1", ImportCardinality.ExactlyOne, true, false); part.AddExport("Export1", 1); part.CallOrder.Enqueue("Import:Import1"); part.CallOrder.Enqueue("OnComposed"); batch.AddExportedValue("Import1", 20); batch.AddPart(part); container.Compose(batch); // Export shouldn't be called until it is pulled on by someone. var export = container.GetExport <object>("Export1"); part.CallOrder.Enqueue("Export:Export1"); Assert.AreEqual(1, export.Value); Assert.IsTrue(part.CallOrder.Count == 0); }