public NuGetBrokeredServiceFactoryTests(GlobalServiceProvider globalServiceProvider) { globalServiceProvider.Reset(); var componentModel = new Mock <IComponentModel>(); var compositionService = new MockCompositionService(); var sourceRepositoryProvider = new Mock <ISourceRepositoryProvider>(); sourceRepositoryProvider.SetupGet(x => x.PackageSourceProvider) .Returns(Mock.Of <IPackageSourceProvider>()); componentModel.SetupGet(x => x.DefaultCompositionService) .Returns(compositionService); componentModel.Setup(x => x.GetService <IVsSolutionManager>()).Returns(Mock.Of <IVsSolutionManager>()); componentModel.Setup(x => x.GetService <ISettings>()).Returns(Mock.Of <ISettings>()); componentModel.Setup(x => x.GetService <ISourceRepositoryProvider>()).Returns(sourceRepositoryProvider.Object); componentModel.Setup(x => x.GetService <INuGetTelemetryProvider>()).Returns(Mock.Of <INuGetTelemetryProvider>()); globalServiceProvider.AddService(typeof(SComponentModel), componentModel.Object); var service = Package.GetGlobalService(typeof(SAsyncServiceProvider)) as IAsyncServiceProvider; ServiceLocator.InitializePackageServiceProvider(service); _serviceFactories = new Dictionary <ServiceRpcDescriptor, BrokeredServiceFactory>(); _authorizingServiceFactories = new Dictionary <ServiceRpcDescriptor, AuthorizingBrokeredServiceFactory>(); }
public void SatisfyImports_AttributedOverride_NullAsAttributedPart() { MockCompositionService compositionService = new MockCompositionService(); ExceptionAssert.ThrowsArgument<ArgumentNullException>("attributedPart", () => { compositionService.SatisfyImportsOnce((object)null); }); }
public void SatisfyImports_AttributedAndBooleanOverride_NullAsAttributedPart() { MockCompositionService compositionService = new MockCompositionService(); Assert.Throws <ArgumentNullException>("attributedPart", () => { compositionService.SatisfyImportsOnce((object)null); }); }
public void SatisfyImports_BooleanOverride_PartAndFalseHaveBeenPassed() { MockCompositionService compositionService = new MockCompositionService(); ComposablePart part = PartFactory.Create(); bool importsSatisfiedCalled = false; compositionService.ImportsSatisfied += delegate(object sender, SatisfyImportsEventArgs e) { Assert.IsFalse(importsSatisfiedCalled); Assert.AreEqual(part, e.Part); importsSatisfiedCalled = true; }; compositionService.SatisfyImportsOnce(part); Assert.IsTrue(importsSatisfiedCalled); }
public void SatisfyImports_BooleanOverride_PartAndFalseHaveBeenPassed() { MockCompositionService compositionService = new MockCompositionService(); ComposablePart part = PartFactory.Create(); bool importsSatisfiedCalled = false; compositionService.ImportsSatisfied += delegate(object sender, SatisfyImportsEventArgs e) { Assert.False(importsSatisfiedCalled); Assert.Equal(part, e.Part); importsSatisfiedCalled = true; }; compositionService.SatisfyImportsOnce(part); Assert.True(importsSatisfiedCalled); }
public void SatisfyImports_AttributedOverride_PartAndFalseHaveBeenPassed() { MockCompositionService compositionService = new MockCompositionService(); object attributedPart = new MockAttributedPart(); bool importsSatisfiedCalled = false; compositionService.ImportsSatisfied += delegate(object sender, SatisfyImportsEventArgs e) { Assert.IsFalse(importsSatisfiedCalled); Assert.IsTrue(e.Part is ReflectionComposablePart); Assert.IsTrue(((ReflectionComposablePart)e.Part).Definition.GetPartType() == typeof(MockAttributedPart)); importsSatisfiedCalled = true; }; compositionService.SatisfyImportsOnce(attributedPart); Assert.IsTrue(importsSatisfiedCalled); }
public void SatisfyImports_AttributedAndBooleanOverride_PartAndFalseHaveBeenPassed() { MockCompositionService compositionService = new MockCompositionService(); object attributedPart = new MockAttributedPart(); bool importsSatisfiedCalled = false; compositionService.ImportsSatisfied += delegate(object sender, SatisfyImportsEventArgs e) { Assert.False(importsSatisfiedCalled); Assert.True(e.Part is ReflectionComposablePart); Assert.True(((ReflectionComposablePart)e.Part).Definition.GetPartType() == typeof(MockAttributedPart)); importsSatisfiedCalled = true; }; compositionService.SatisfyImportsOnce(attributedPart); Assert.True(importsSatisfiedCalled); }
public NuGetBrokeredServiceFactoryTests(GlobalServiceProvider globalServiceProvider) { globalServiceProvider.Reset(); var componentModel = new Mock <IComponentModel>(); var compositionService = new MockCompositionService(); componentModel.SetupGet(x => x.DefaultCompositionService) .Returns(compositionService); var sourceRepositoryProvider = new Mock <ISourceRepositoryProvider>(); sourceRepositoryProvider.SetupGet(x => x.PackageSourceProvider) .Returns(Mock.Of <IPackageSourceProvider>()); globalServiceProvider.AddService(typeof(IVsSolutionManager), Mock.Of <IVsSolutionManager>()); globalServiceProvider.AddService(typeof(ISettings), Mock.Of <ISettings>()); globalServiceProvider.AddService(typeof(ISourceRepositoryProvider), sourceRepositoryProvider.Object); globalServiceProvider.AddService(typeof(SComponentModel), componentModel.Object); _serviceFactories = new Dictionary <ServiceRpcDescriptor, BrokeredServiceFactory>(); _authorizingServiceFactories = new Dictionary <ServiceRpcDescriptor, AuthorizingBrokeredServiceFactory>(); }