Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceProviderBuilderBase{TDerived}" /> class.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="context">The context.</param>
 /// <param name="trace">The tracing service.</param>
 protected ServiceProviderBuilderBase(IOrganizationService service, IPluginExecutionContext context, ITracingService trace)
 {
     ServiceProvider = new FakeServiceProvider();
     ServiceProvider.AddService <IOrganizationServiceFactory>(new FakeOrganizationServiceFactory(service));
     ServiceProvider.AddService(context);
     ServiceProvider.AddService(trace);
 }
Ejemplo n.º 2
0
        public void IServiceProvider_GetFake_Should_RetrieveTheInstance()
        {
            var provider = new FakeServiceProvider();
            var service  = new FakeIOrganizationService(new LocalCrmDatabaseOrganizationService(LocalCrmDatabaseInfo.Create <CrmContext>()));

            provider.AddService <IOrganizationService>(service);
            var fake = provider.GetFake <FakeIOrganizationService>();

            Assert.IsNotNull(fake);
            Assert.AreEqual(service, fake);
        }
Ejemplo n.º 3
0
        public void GetService_HostPassedFakeServiceProvider_ReturnsServiceFromFakeServiceProvider()
        {
            CreateHost();
            var expectedService = new StringWriter();

            fakeServiceProvider.AddService(typeof(StringWriter), expectedService);

            var          hostServiceProvider = host as IServiceProvider;
            StringWriter service             = hostServiceProvider.GetService(typeof(StringWriter)) as StringWriter;

            Assert.AreEqual(expectedService, service);
        }