public void SerializeAndDeserialize_WithNewBindableObjectProvider() { SimpleBusinessObjectClass value = ObjectFactory.Create <SimpleBusinessObjectClass> (ParamList.Empty); byte[] serialized = Serializer.Serialize(value); BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), null); SimpleBusinessObjectClass deserialized = (SimpleBusinessObjectClass)Serializer.Deserialize(serialized); Assert.That(((IBusinessObject)deserialized).BusinessObjectClass, Is.Not.SameAs(((IBusinessObject)value).BusinessObjectClass)); }
public override void SetUp() { base.SetUp(); _serviceFactoryStub = MockRepository.GenerateStub <IBusinessObjectServiceFactory>(); _provider = new StubBusinessObjectProvider(_serviceFactoryStub); _mockRepository = new MockRepository(); BusinessObjectProvider.SetProvider <StubBusinessObjectProviderAttribute> (null); BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (null); }
public override void SetUp() { base.SetUp(); _mockRepository = new MockRepository(); _bindableObjectProviderForDeclaringType = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory(); _bindableObjectProviderForPropertyType = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory(); BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProviderForDeclaringType); BusinessObjectProvider.SetProvider <BindableObjectProviderForDefaultValueServiceAttribute> (_bindableObjectProviderForPropertyType); }
public override void SetUp() { base.SetUp(); _mockRepository = new MockRepository(); _bindableObjectProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory(); _bindableObjectWithIdentityProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory(); BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProvider); BusinessObjectProvider.SetProvider <BindableObjectWithIdentityProviderAttribute> (_bindableObjectWithIdentityProvider); }
public void SerializeAndDeserialize_WithNewBindableObjectProvider() { SampleBindableMixinDomainObject value = SampleBindableMixinDomainObject.NewObject(); byte[] serialized = Serializer.Serialize(Tuple.Create(TestableClientTransaction, value)); BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null); var deserialized = (Tuple <ClientTransaction, SampleBindableMixinDomainObject>)Serializer.Deserialize(serialized); using (deserialized.Item1.EnterDiscardingScope()) { Assert.That(((IBusinessObject)deserialized.Item2).BusinessObjectClass, Is.Not.SameAs(((IBusinessObject)value).BusinessObjectClass)); } }
public void TestGetExtetnts() { IProvider p = null; var data = PointsOfInterest.Create(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data)); var e = p.GetExtents(); var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source; var e2 = bop.GetExtents(); Assert.AreEqual(e, e2); Assert.AreEqual(new Envelope(0, 2, 0, 2), e); }
public void TestGetExtents() { IProvider p = null; var source = new BusinessObjectSource <Country>(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(source)); var e = p.GetExtents(); var bop = source; var e2 = bop.GetExtents(); Assert.AreEqual(e, e2); Assert.IsTrue(new Envelope(-180, 181, -90, 90).Contains(e)); }
private IGetObjectService GetGetObjectService() { var service = (IGetObjectService)BusinessObjectProvider.GetService(_getObjectServiceType); if (service == null) { throw new InvalidOperationException( string.Format( "The '{0}' required for loading objectes of type '{1}' is not registered with the '{2}' associated with this type.", _getObjectServiceType.FullName, TargetType.FullName, typeof(BusinessObjectProvider).FullName)); } return(service); }
public void TestAsReadOnly() { IProvider p = null; var data = PointsOfInterest.Create(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data)); var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source; // select all business objects PointOfInterest[] pts; pts = bop.AsReadOnly(); Assert.NotNull(pts); Assert.AreEqual(pts.Length, 9); }
public void TestAttributeSelectionMulti() { IProvider p = null; var data = PointsOfInterest.Create(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data)); var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source; // select 5 business objects PointOfInterest[] pts; pts = bop.FindAll(b => b.ID < 6 && b.Kind == "African food"); Assert.NotNull(pts); Assert.AreEqual(pts.Length, 5); }
public void SetUp() { try { BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null); _dbFixtures = new DatabaseFixtures(); _dbFixtures.CreateAndCommitOrganizationalStructureWithTwoTenants(ClientTransaction.CreateRootTransaction()); } catch (Exception e) { Console.WriteLine(e); throw; } }
public void SetUp() { var stubSecurityProvider = new StubSecurityProvider(); var threadPrincipalProvider = new ThreadPrincipalProvider(); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle <ISecurityProvider> (() => stubSecurityProvider); serviceLocator.RegisterSingle <IPrincipalProvider> (() => threadPrincipalProvider); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); var clientTransaction = new SecurityClientTransactionFactory().CreateRootTransaction(); clientTransaction.To <ClientTransaction>().EnterDiscardingScope(); BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null); }
public void TestExecuteFeatureQuery() { IProvider p = null; var data = PointsOfInterest.Create(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data)); var fds = new FeatureDataSet(); p.ExecuteIntersectionQuery(new Envelope(0.5, 1.5, 0.5, 1.5), fds); Assert.AreEqual(1, fds.Tables.Count); Assert.AreEqual("PointOfInterest", fds.Tables[0].TableName); Assert.AreEqual(1, fds.Tables[0].Rows.Count); Assert.AreEqual(5, fds.Tables[0].Rows[0]["ID"]); Assert.AreEqual(new Coordinate(1, 1), ((FeatureDataRow)fds.Tables[0].Rows[0]).Geometry.Coordinate); }
private IBusinessObjectClassService GetBusinessObjectClassService() { IBusinessObjectClassService service = BusinessObjectProvider.GetService <IBusinessObjectClassService>(); if (service == null) { throw new InvalidOperationException( string.Format( "The '{0}' type does not use the '{1}' implementation of '{2}' and there is no '{3}' registered with the '{4}' associated with this type.", UnderlyingType.FullName, typeof(BindableObjectMixin).Namespace, typeof(IBusinessObject).FullName, typeof(IBusinessObjectClassService).FullName, typeof(BusinessObjectProvider).FullName)); } return(service); }
public void ProviderTest() { BusinessObjectProvider <University> p = null; Assert.DoesNotThrow(() => p = new BusinessObjectProvider <University>("XYZ", new EF6BusinessObjectSource <University>(() => new UniversityContext()))); Assert.IsNotNull(p); Assert.AreEqual(2, p.GetFeatureCount()); Envelope env = null; Assert.DoesNotThrow(() => env = p.GetExtents()); Assert.IsNotNull(env); Assert.IsFalse(env.IsNull); var fds = new FeatureDataSet(); Assert.DoesNotThrow(() => p.ExecuteIntersectionQuery(env, fds)); Assert.AreEqual(1, fds.Tables.Count); Assert.AreEqual(2, fds.Tables[0].Rows.Count); fds = new FeatureDataSet(); var f = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(0); var pBuf = f.CreatePoint(new Coordinate(-122.296623, 47.640405)).Buffer(0.001); Assert.DoesNotThrow(() => p.ExecuteIntersectionQuery(pBuf, fds)); Assert.AreEqual(1, fds.Tables.Count); Assert.GreaterOrEqual(1, fds.Tables[0].Rows.Count); fds = new FeatureDataSet(); var r = p.Source as EF6BusinessObjectSource <University>; using (var c = r.Context) { var pDbBuf = pBuf.ToDbGeometry(); var q = from u in c.Set <University>() where u.Name == "Graphic Design Institute" || u.DbGeometry.Intersects(pDbBuf) orderby u.Name select u; Assert.DoesNotThrow(() => p.ExecuteQueryable(q, fds)); } Assert.AreEqual(1, fds.Tables.Count); Assert.GreaterOrEqual(2, fds.Tables[0].Rows.Count); }
public void TestExecuteFeatureQuery1() { IProvider p = null; var source = new BusinessObjectSource <Country>(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(source)); var fds = new FeatureDataSet(); //http://tools.wmflabs.org/geohack/geohack.php?pagename=Bonn&language=de¶ms=50.719113888889_N_7.1175722222222_E_region:DE-NW_type:landmark&title=Bundeskanzlerplatz var bn = new Coordinate(7.1175722222222, 50.719113888889); var e = new Envelope(bn).Grow(0.00001); p.ExecuteIntersectionQuery(e, fds); Assert.AreEqual(1, fds.Tables.Count); Assert.AreEqual("Country", fds.Tables[0].TableName); Assert.AreEqual(5, fds.Tables[0].Rows.Count); }
public void TestExecuteFeatureQuery2() { IProvider p = null; var source = new BusinessObjectSource <Country>(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(source)); var fds = new FeatureDataSet(); //http://tools.wmflabs.org/geohack/geohack.php?pagename=Bonn&language=de¶ms=50.719113888889_N_7.1175722222222_E_region:DE-NW_type:landmark&title=Bundeskanzlerplatz var bn = new Coordinate(7.1175722222222, 50.719113888889); var pt = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreatePoint(bn); p.ExecuteIntersectionQuery(pt, fds); Assert.AreEqual(1, fds.Tables.Count); Assert.AreEqual("Country", fds.Tables[0].TableName); Assert.AreEqual(1, fds.Tables[0].Rows.Count); }
public void SearchSpecificGroups() { var property = (IBusinessObjectReferenceProperty)_aceClass.GetPropertyDefinition("SpecificGroup"); Assert.That(property, Is.Not.Null); var expected = new[] { MockRepository.GenerateStub <IBusinessObject>() }; BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>() .AddService(typeof(GroupPropertyTypeSearchService), _searchServiceStub); _searchServiceStub.Stub(stub => stub.SupportsProperty(property)).Return(true); _searchServiceStub.Stub(stub => stub.Search(_ace, property, _searchServiceArgsStub)).Return(expected); Assert.That(property.SupportsSearchAvailableObjects, Is.True); IBusinessObject[] actual = property.SearchAvailableObjects(_ace, _searchServiceArgsStub); Assert.That(actual, Is.EquivalentTo(expected)); }
private IBusinessObjectClass GetReferenceClassFromService() { IBusinessObjectClassService service = GetBusinessObjectClassService(); IBusinessObjectClass businessObjectClass = service.GetBusinessObjectClass(UnderlyingType); if (businessObjectClass == null) { throw new InvalidOperationException( string.Format( "The GetBusinessObjectClass method of '{0}', registered with the '{1}', failed to return an '{2}' for type '{3}'.", service.GetType().FullName, BusinessObjectProvider.GetType().FullName, typeof(IBusinessObjectClass).FullName, UnderlyingType.FullName)); } return(businessObjectClass); }
public override void SetUp() { base.SetUp(); _mockRepository = new MockRepository(); _mockStringFormatterService = _mockRepository.StrictMock <IBusinessObjectStringFormatterService>(); BindableObjectProvider provider = new BindableObjectProvider(); provider.AddService(typeof(IBusinessObjectStringFormatterService), _mockStringFormatterService); BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), provider); _businessObject = (IBusinessObject)ObjectFactory.Create <SimpleBusinessObjectClass> (ParamList.Empty); _property = _businessObject.BusinessObjectClass.GetPropertyDefinition("String"); Assert.That( _property, Is.Not.Null, "Property 'String' was not found on BusinessObjectClass '{0}'", _businessObject.BusinessObjectClass.Identifier); BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), new BindableObjectProvider()); }
public void TestAttributeDelete() { IProvider p = null; var data = PointsOfInterest.Create(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data)); var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source; var cnt = bop.Count; var env = bop.GetExtents(); // delete 3 features on RHS bop.Delete(b => b.Address == "rl" || b.Address == "cr" || b.Address == "tr"); Assert.AreEqual(bop.Count, cnt - 3); Assert.That(env.Width == 2 && env.Height == 2); Assert.That(bop.GetExtents().Width == 1 && bop.GetExtents().Height == 2); }
public void TestAttributeUpdate() { IProvider p = null; var data = PointsOfInterest.Create(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data)); var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source; // update single business object var bo = bop.Find(b => b.Address == "lc"); Assert.AreEqual(bo.Kind, "African food"); bo.Kind = "Indian food"; FeatureDataRow row = null; Assert.DoesNotThrow(() => row = p.GetFeature(4)); Assert.IsNotNull(row); Assert.AreEqual(bo.Kind, row["Kind"]); }
public void TestWithProvider() { MongoDbBusinessObjectSource <PoI, GeoJson2DCoordinates> repo = null; Assert.DoesNotThrow(() => repo = new PoIRepository( GeoJsonConverter.Converter2D, TestConnection, TestDatabase, TestCollection)); var p = new BusinessObjectProvider <PoI>(TestCollection, repo); var vl = new VectorLayer(p.ConnectionID, p); var bl = new BusinessObjectLayer <PoI>(repo); var m = new Map(); m.Layers.Add(vl); m.Layers.Add(bl); m.ZoomToExtents(); m.GetMap().Save("MongoDB.PoI.png", ImageFormat.Png); m.Dispose(); }
public void SetUp() { var bindablePropertyReadAccessStrategy = new CompundBindablePropertyReadAccessStrategy( new IBindablePropertyReadAccessStrategy[] { new BindableDomainObjectPropertyReadAccessStrategy() }); var bindablePropertyWriteAccessStrategy = new CompundBindablePropertyWriteAccessStrategy( new IBindablePropertyWriteAccessStrategy[] { new BindableDomainObjectPropertyWriteAccessStrategy() }); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle <IBindablePropertyReadAccessStrategy> (() => bindablePropertyReadAccessStrategy); serviceLocator.RegisterSingle <IBindablePropertyWriteAccessStrategy> (() => bindablePropertyWriteAccessStrategy); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); _disableAccessChecksBackup = SecurityConfiguration.Current.DisableAccessChecks; SecurityConfiguration.Current.DisableAccessChecks = true; ClientTransaction.CreateRootTransaction().EnterDiscardingScope(); BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null); }
public override void SetUp() { base.SetUp(); _searchServiceTestHelper = new SearchServiceTestHelper(); _stubbedQueryID = "FakeQuery"; BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>().AddService( typeof(ISearchAvailableObjectsService), new BindableDomainObjectCompoundSearchService()); _clientTransaction = _searchServiceTestHelper.CreateStubbableTransaction <ClientTransaction>(); _transactionScope = _clientTransaction.EnterDiscardingScope(); var fakeResultData = _searchServiceTestHelper.CreateFakeResultData(_clientTransaction); _searchServiceTestHelper.StubQueryResult(_stubbedQueryID, new[] { fakeResultData }); var referencingObject = SampleBindableMixinDomainObject.NewObject(); _referencingBusinessObject = (IBusinessObject)referencingObject; _property = (IBusinessObjectReferenceProperty)_referencingBusinessObject.BusinessObjectClass.GetPropertyDefinition("Relation"); }
public void TestGetFeature() { IProvider p = null; var data = PointsOfInterest.Create(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(data)); FeatureDataRow row = null; Assert.DoesNotThrow(() => row = p.GetFeature(1)); Assert.IsNotNull(row); Assert.IsNotNull(row.Geometry); Assert.AreEqual(OgcGeometryType.Point, row.Geometry.OgcGeometryType); Assert.AreEqual(new Coordinate(0, 0), row.Geometry.Coordinate); var bop = ((BusinessObjectProvider <PointOfInterest>)p).Source; var bo = bop.Select(1); Assert.AreEqual(bo.ID, row["ID"]); Assert.AreEqual(bo.Geometry, row.Geometry); Assert.AreEqual(bo.Address, row["Address"]); }
public void TestGetFeature() { IProvider p = null; var source = new BusinessObjectSource <Country>(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(source)); FeatureDataRow row = null; Assert.DoesNotThrow(() => row = p.GetFeature(1)); Assert.IsNotNull(row); Assert.IsNotNull(row.Geometry); Assert.AreEqual(OgcGeometryType.MultiPolygon, row.Geometry.OgcGeometryType); //Assert.AreEqual(new Coordinate(0, 0), row.Geometry.Coordinate); var bop = source; var bo = bop.Select(1); Assert.AreEqual(bo.PKID, row["PKID"]); Assert.IsTrue(bo.Geometry.EqualsExact(row.Geometry)); Assert.AreEqual(bo.Admin, row["Admin"]); }
public void TestGetMap() { using (var m = new Map(new Size(720, 360))) { VectorRenderer.SizeOfString = (g, s, f) => TextRenderer.MeasureText(g, s, f); m.BackColor = Color.White; IProvider p = null; var source = new BusinessObjectSource <Country>(); Assert.DoesNotThrow(() => p = BusinessObjectProvider.Create(source)); m.Layers.Add(new VectorLayer("Countries", p)); var ll = new LabelLayer("CountryLabels"); ll.DataSource = p; ll.LabelStringDelegate = (fdr) => string.Format("{0} - {1}", fdr["PKID"], fdr["Admin"]); ll.PriorityDelegate = (fdr) => (int)fdr.Geometry.Area; ll.MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.Largest; ll.LabelFilter = Rendering.LabelCollisionDetection.ThoroughCollisionDetection; ll.Style.Halo = new Pen(Color.Wheat, 2f) { LineJoin = LineJoin.MiterClipped }; ll.Style.ForeColor = Color.Brown; ll.Style.CollisionBuffer = new SizeF(2, 2); ll.Style.CollisionDetection = true; m.Layers.Add(ll); m.ZoomToExtents(); m.Zoom *= 1.1; using (var img = m.GetMap()) { img.Save("CountriesImage.png", ImageFormat.Png); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Type itemType = GetType(); PropertyInfo propertyInfo = itemType.GetProperty("ConformanceLevel"); EnumerationProperty property = new EnumerationProperty( new PropertyBase.Parameters( (BindableObjectProvider)BusinessObjectProvider.GetProvider <BindableObjectProviderAttribute>(), PropertyInfoAdapter.Create(propertyInfo), propertyInfo.PropertyType, new Lazy <Type> (() => propertyInfo.PropertyType), null, false, false, new BindableObjectDefaultValueStrategy(), SafeServiceLocator.Current.GetInstance <IBindablePropertyReadAccessStrategy>(), SafeServiceLocator.Current.GetInstance <IBindablePropertyWriteAccessStrategy>(), SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>())); WaiConformanceLevelField.Property = property; WaiConformanceLevelField.LoadUnboundValue(ConformanceLevel, IsPostBack); }
public override void SetUp() { base.SetUp(); BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null); _securityProviderStub = MockRepository.GenerateStub <ISecurityProvider>(); _principalProviderStub = MockRepository.GenerateStub <IPrincipalProvider>(); _securityPrincipalStub = MockRepository.GenerateStub <ISecurityPrincipal>(); _principalProviderStub.Stub(stub => stub.GetPrincipal()).Return(_securityPrincipalStub); _clientTransaction = ClientTransaction.CreateRootTransaction(); _clientTransaction.Extensions.Add(new SecurityClientTransactionExtension()); _clientTransaction.EnterNonDiscardingScope(); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle(() => _securityProviderStub); serviceLocator.RegisterSingle(() => _principalProviderStub); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); }