IBusinessObjectWithIdentity IGetObjectService.GetObject(BindableObjectClassWithIdentity classWithIdentity, string uniqueIdentifier) { ArgumentUtility.CheckNotNull("classWithIdentity", classWithIdentity); ArgumentUtility.CheckNotNullOrEmpty("uniqueIdentifier", uniqueIdentifier); return((IBusinessObjectWithIdentity)GetObject(classWithIdentity.TargetType, new Guid(uniqueIdentifier))); }
public void GetObject_WithoutService() { var bindableObjectClass = new BindableObjectClassWithIdentity( MixinTypeUtility.GetConcreteMixedType(typeof(ClassWithIdentity)), _bindableObjectProvider, _bindableObjectGlobalizationService, new PropertyBase[0]); bindableObjectClass.GetObject("TheUniqueIdentifier"); }
public override void SetUp() { base.SetUp(); _service = new BindableDomainObjectGetObjectService(); _instance = SampleBindableDomainObject.NewObject(); _businessObjectClass = (BindableObjectClassWithIdentity)((IBusinessObject)_instance).BusinessObjectClass; _id = ((IBusinessObjectWithIdentity)_instance).UniqueIdentifier; }
public void Initialize() { var bindableObjectClass = new BindableObjectClassWithIdentity( MixinTypeUtility.GetConcreteMixedType(typeof(ClassWithIdentity)), _bindableObjectProvider, _bindableObjectGlobalizationService, new PropertyBase[0]); Assert.That(bindableObjectClass.TargetType, Is.SameAs(typeof(ClassWithIdentity))); Assert.That( bindableObjectClass.Identifier, Is.EqualTo("Remotion.ObjectBinding.UnitTests.TestDomain.ClassWithIdentity, Remotion.ObjectBinding.UnitTests")); Assert.That(bindableObjectClass.RequiresWriteBack, Is.False); Assert.That(bindableObjectClass.BusinessObjectProvider, Is.SameAs(_bindableObjectProvider)); }
public void GetObject_WithCustomService() { var bindableObjectClass = new BindableObjectClassWithIdentity( MixinTypeUtility.GetConcreteMixedType(typeof(ClassWithIdentityAndGetObjectServiceAttribute)), _bindableObjectProvider, _bindableObjectGlobalizationService, new PropertyBase[0]); var mockService = _mockRepository.StrictMock <ICustomGetObjectService>(); var expected = _mockRepository.Stub <IBusinessObjectWithIdentity>(); Expect.Call(mockService.GetObject(bindableObjectClass, "TheUniqueIdentifier")).Return(expected); _mockRepository.ReplayAll(); _bindableObjectProvider.AddService(typeof(ICustomGetObjectService), mockService); IBusinessObjectWithIdentity actual = bindableObjectClass.GetObject("TheUniqueIdentifier"); _mockRepository.VerifyAll(); Assert.That(actual, Is.SameAs(expected)); }
public IBusinessObjectWithIdentity GetObject(BindableObjectClassWithIdentity classWithIdentity, string uniqueIdentifier) { ArgumentUtility.CheckNotNull("classWithIdentity", classWithIdentity); ArgumentUtility.CheckNotNullOrEmpty("uniqueIdentifier", uniqueIdentifier); var objectID = ObjectID.Parse(uniqueIdentifier); var domainObjectOrNull = LifetimeService.TryGetObject(ClientTransaction.Current, objectID); if (domainObjectOrNull == null) { return(null); } if (domainObjectOrNull.State == StateType.Invalid) { return(null); } if (domainObjectOrNull.State == StateType.Deleted) { return(null); } return((IBusinessObjectWithIdentity)domainObjectOrNull); }
public IBusinessObjectWithIdentity GetObject(BindableObjectClassWithIdentity classWithIdentity, string uniqueIdentifier) { return(_objectToReturn); }