Example #1
0
        public void GetService_FromServiceFactory()
        {
            MockRepository mockRepository = new MockRepository();
            IBusinessObjectServiceFactory         serviceFactoryMock = mockRepository.StrictMock <IBusinessObjectServiceFactory>();
            IBusinessObjectStringFormatterService serviceStub        = MockRepository.GenerateStub <IBusinessObjectStringFormatterService>();
            BusinessObjectProvider provider = new StubBusinessObjectProvider(serviceFactoryMock);

            Expect.Call(serviceFactoryMock.CreateService(provider, typeof(IBusinessObjectStringFormatterService))).Return(serviceStub);

            mockRepository.ReplayAll();

            IBusinessObjectService actual  = provider.GetService(typeof(IBusinessObjectStringFormatterService));
            IBusinessObjectService actual2 = provider.GetService(typeof(IBusinessObjectStringFormatterService));

            mockRepository.VerifyAll();

            Assert.That(actual, Is.SameAs(serviceStub));
            Assert.That(actual, Is.SameAs(actual2));
        }
Example #2
0
 public void GetService_FromSubstitutionPropertiesSearchService()
 {
     Assert.That(
         _serviceFactory.CreateService(_bindableObjectProvider, typeof(SubstitutionPropertiesSearchService)),
         Is.InstanceOf(typeof(SubstitutionPropertiesSearchService)));
 }
 public void GetService_FromIBusinessObjectStringFormatterService()
 {
     Assert.That(
         _serviceFactory.CreateService(_bindableDomainObjectProvider, typeof(IBusinessObjectStringFormatterService)),
         Is.InstanceOf(typeof(BusinessObjectStringFormatterService)));
 }
        /// <summary> Retrieves the requested <see cref="IBusinessObjectService"/>. Must not be <see langword="null" />.</summary>
        public IBusinessObjectService GetService(Type serviceType)
        {
            ArgumentUtility.CheckNotNullAndTypeIsAssignableFrom("serviceType", serviceType, typeof(IBusinessObjectService));

            IDataStore <Type, IBusinessObjectService> serviceStore = ServiceStore;

            Assertion.IsNotNull(serviceStore, "The ServiceStore evaluated and returned null. It should return a null object instead.");

            return(serviceStore.GetOrCreateValue(serviceType, delegate(Type type) { return _serviceFactory.CreateService(this, type); }));
        }