Exemple #1
0
        private bool ValidContainer(object container)
        {
            //TODO: Check for nested containers and already existing containers with this ViewManager
            if (_registry.FallbackBinding != null && _registry.FallbackBinding.Container == container)
            {
                return(true);
            }
            foreach (object registeredContainer in _containers)
            {
                if (container == registeredContainer)
                {
                    return(false);
                }

                if (_registry.FallbackBinding != null && _registry.FallbackBinding.Container == registeredContainer)
                {
                    return(false);
                }

                if (_registry.Contains(registeredContainer, container) || _registry.Contains(container, registeredContainer))
                {
                    throw new Exception("Containers can not be nested");
                }
            }
            return(true);
        }
        public void Parent_Finder_Positive()
        {
            bool   contains = true;
            object parent   = new object();

            registry.SetParentFinder(new CustomParentFinder(contains, parent));
            List <ContainerBinding> nullList = null;
            object expectedParent            = registry.FindParent(null, nullList);
            object expectedContains          = registry.Contains(null, nullList);

            Assert.That(contains, Is.EqualTo(expectedContains));
            Assert.That(parent, Is.EqualTo(parent));
        }