public void SetImport_WrongTypeExportGiven_ShouldThrowComposablePart()
        {
            var part   = CreatePart(new MySharedPartExport());
            var import = part.ImportDefinitions.First();

            CompositionAssert.ThrowsPart(() =>
            {
                part.SetImport(import, CreateSimpleExports("21"));
            });
        }
        public void SetImport_WrongTypeExportGiven_ShouldThrowComposablePart()
        {
            var part   = CreatePart(new MySharedPartExport());
            var import = part.ImportDefinitions.First();

            CompositionAssert.ThrowsPart(ErrorId.ReflectionModel_ImportNotAssignableFromExport, () =>
            {
                part.SetImport(import, CreateSimpleExports("21"));
            });
        }
        public void GetExportedValue_UnhandledExceptionThrowInConstructor_ShouldThrowComposablePart()
        {
            var part = CreatePart(typeof(ExportWithExceptionDuringConstruction));

            var definition = part.ExportDefinitions.First();

            CompositionAssert.ThrowsPart <NotImplementedException>(() =>
            {
                part.GetExportedValue(definition);
            });
        }
        public void GetExportedValue_NoConstructorOnDefinition_ShouldThrowComposablePart()
        {
            var part = CreatePart(typeof(ClassWithNoMarkedOrDefaultConstructor));

            var definition = part.ExportDefinitions.First();

            CompositionAssert.ThrowsPart(() =>
            {
                part.GetExportedValue(definition);
            });
        }
        public void OnComposed_UnhandledExceptionThrowInOnImportsSatisfied_ShouldThrowComposablePart()
        {
            var part       = CreatePart(typeof(ExceptionDuringINotifyImport));
            var definition = part.ImportDefinitions.First();

            part.SetImport(definition, CreateSimpleExports(21));

            CompositionAssert.ThrowsPart <NotImplementedException>(RetryMode.DoNotRetry, () =>
            {
                part.Activate();
            });
        }