public void GetExports_ExtensibilityPart_ReturnsEmpty()
        {
            var strategy  = new FilterablePluginContextStrategy(_path, FakeFilterableIds.AlphaFakeId);
            var container = strategy.CreateContainer();

            Assert.Empty(container.GetExports <IExtensibilityPart>());
        }
        public void GetExport_IFilterableFakePartWithComposedDependencies_IsRecomposed()
        {
            var strategy   = new FilterablePluginContextStrategy(_path, FakeFilterableIds.AlphaFakeId);
            var container  = strategy.CreateContainer();
            var dependency = container.GetExport <IFilterableFakeDependency>();

            IFilterableFakePartWithComposedDependencies part = null !;

            DependencyRegistry <IFilterableFakeDependency>
            .ExecuteWhileArmed(dependency,
                               () => part = container.GetExport <IFilterableFakePartWithComposedDependencies>());

            var newDependency = container.GetExport <IFilterableFakeDependency>();

            IFilterableFakePartWithComposedDependencies newPart = null !;

            DependencyRegistry <IFilterableFakeDependency>
            .ExecuteWhileArmed(newDependency,
                               () => newPart = container.GetExport <IFilterableFakePartWithComposedDependencies>());

            Assert.NotNull(newPart);
            Assert.Equal(newDependency, newPart.Dependency);
            Assert.NotNull(part);
            Assert.NotEqual(part.Dependency, newPart.Dependency);
        }
        public void GetExport_GammaFilterableType_IsShared()
        {
            var strategy   = new FilterablePluginContextStrategy(_path, FakeFilterableIds.GammaFakeId);
            var container  = strategy.CreateContainer();
            var firstPart  = container.GetExport <IFilterableFakePart>();
            var secondPart = container.GetExport <IFilterableFakePart>();

            Assert.Equal(firstPart, secondPart);
        }
        public void GetExport_SingleFilterableTypes_ReturnsPartFromFamily(string fakeId)
        {
            var strategy  = new FilterablePluginContextStrategy(_path, new Guid(fakeId));
            var container = strategy.CreateContainer();
            var part      = container.GetExport <IFilterableFakePart>();

            Assert.NotNull(part);
            Assert.Equal(new Guid(fakeId), part.FamilyId);
        }
        public void GetExports_FilterableTypes_ReturnsPartsFromFamily(string fakeId)
        {
            var strategy  = new FilterablePluginContextStrategy(_path, new Guid(fakeId));
            var container = strategy.CreateContainer();
            var parts     = container.GetExports <IFilterableFakePart>().ToList();

            Assert.NotEmpty(parts);
            Assert.All(parts, p => Assert.Equal(new Guid(fakeId), p.FamilyId));
        }
        public void GetExport_IFilterableFakePartWithDependencies_ReturnsPartWithDependency()
        {
            var strategy   = new FilterablePluginContextStrategy(_path, FakeFilterableIds.AlphaFakeId);
            var container  = strategy.CreateContainer();
            var part       = container.GetExport <IFilterableFakePartWithDependencies>();
            var dependency = container.GetExport <IFilterableFakeDependency>();

            Assert.NotNull(part);
            Assert.NotNull(part.Dependency);
            Assert.NotNull(dependency);
            Assert.Equal(part.Dependency.GetType(), dependency.GetType());
        }
        public void GetExport_IFilterableFakePartWithComposedDependencies_ReturnsPartWithDependency()
        {
            var strategy   = new FilterablePluginContextStrategy(_path, FakeFilterableIds.AlphaFakeId);
            var container  = strategy.CreateContainer();
            var dependency = container.GetExport <IFilterableFakeDependency>();

            DependencyRegistry <IFilterableFakeDependency>
            .ExecuteWhileArmed(dependency,
                               () =>
            {
                var part = container.GetExport <IFilterableFakePartWithComposedDependencies>();
                Assert.NotNull(part);
                Assert.Equal(dependency, part.Dependency);
            });
        }