public void Should_register_unscoped_data_provider_and_resolve_scoped() { var personProvider = new PersonProvider1(_dataProviderDependenciesFactory); var builtDataProvider = _fluentBuilder.BuildUpDataProvider(personProvider).Build(); Assert.IsNotNull(builtDataProvider); var dataProvider = _nameManager.ResolveDataProvider(personProvider.Name); Assert.IsTrue(ReferenceEquals(dataProvider, personProvider)); var dependency = _dataProviderDependenciesFactory.DataDependencyFactory.Create <Person>("scope"); var dataSupplier = _dataCatalog.FindSupplier(dependency); Assert.IsNotNull(dataSupplier); var dataSupply = dataSupplier.GetSupply(dependency); Assert.IsNotNull(dataSupply); var renderContext = SetupMock <IRenderContext>(); var dataContext = SetupMock <IDataContext>(); dataSupply.Supply(renderContext, dataContext); var person = dataContext.Get <Person>(); Assert.IsNotNull(person); Assert.AreEqual("Martin", person.FirstName); Assert.AreEqual("Halliday", person.LastName); }
public void Should_distinguish_unscoped_data_provider() { var personProvider1 = new PersonProvider1(_dataProviderDependenciesFactory); _fluentBuilder.BuildUpDataProvider(personProvider1).Build(); var personProvider2 = new PersonProvider2(_dataProviderDependenciesFactory); _fluentBuilder.BuildUpDataProvider(personProvider2).Build(); var dependency1 = _dataProviderDependenciesFactory.DataDependencyFactory.Create <Person>(); var dataSupplier1 = _dataCatalog.FindSupplier(dependency1); var dataSupply = dataSupplier1.GetSupply(dependency1); Assert.IsNotNull(dataSupply); var renderContext = SetupMock <IRenderContext>(); var dataContext = SetupMock <IDataContext>(); dataSupply.Supply(renderContext, dataContext); var person = dataContext.Get <Person>(); Assert.IsNotNull(person); Assert.AreEqual("Martin", person.FirstName); Assert.AreEqual("Halliday", person.LastName); }