/// <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); }
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); }
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); }