private ProjectCollectionLinker(ConnectedProjectCollections group) { this.LinkedCollections = group; this.CollectionId = (UInt32)Interlocked.Increment(ref _collecitonId); this.Collection = new ProjectCollection(); this.LinkFactory = LinkedObjectsFactory.Get(this.Collection); }
private static void VerifyProjectElementContainerView(ProjectElementContainer viewXml, ProjectElementContainer realXml, ValidationContext context = null) { if (viewXml == null && realXml == null) { return; } VerifyProjectElementViewInternal(viewXml, realXml, context); Assert.Equal(realXml.Count, viewXml.Count); VerifyNotLinked(realXml.FirstChild); VerifyLinked(viewXml.FirstChild); VerifyNotLinked(realXml.LastChild); VerifyLinked(viewXml.LastChild); var realChild = realXml.FirstChild; var viewChild = viewXml.FirstChild; while (realChild != null) { Assert.NotNull(viewChild); Assert.Same(realChild.Parent, realXml); if (!object.ReferenceEquals(viewChild.Parent, viewXml)) { var lm = LinkedObjectsFactory.GetLink(viewXml) as ILinkMock; lm.Linker.ValidateNoDuplicates(); } Assert.Same(viewChild.Parent, viewXml); if (realChild is ProjectElementContainer realChildContainer) { Assert.True(viewChild is ProjectElementContainer); VerifyProjectElementContainerView((ProjectElementContainer)viewChild, realChildContainer, context); } else { Assert.False(viewChild is ProjectElementContainer); VerifyProjectElementViewInternal(viewChild, realChild, context); } realChild = realChild.NextSibling; viewChild = viewChild.NextSibling; } Assert.Null(viewChild); }
// note this is a cheat, it relies on Mock implementation knowledge and that we are in the same process. public static T GetRealObject <T>(T view) where T : class { if (view == null) { return(null); } if (!IsLinkedObject(view)) { return(view); } var link = LinkedObjectsFactory.GetLink(view) as ILinkMock; Assert.NotNull(link); var remoter = link.Remoter as IRemoterSource; Assert.NotNull(remoter); var real = remoter.RealObject as T; Assert.NotNull(real); VerifyFindType(view, real); return(real); }
public static bool IsLinkedObject(object obj) { return(LinkedObjectsFactory.GetLink(obj) != null); }