Ejemplo n.º 1
0
        public void RegisterSiteAdapterTwiceThrows()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("Foo", new MockAdapter());
            collection.RegisterSite("Foo", new MockAdapter());
        }
Ejemplo n.º 2
0
        public void TryingToOverrideParentSiteThrows()
        {
            UIExtensionSiteCollection parent = new UIExtensionSiteCollection();
            UIExtensionSiteCollection child  = new UIExtensionSiteCollection(parent);

            parent.RegisterSite("Foo", new MockAdapter());
            child.RegisterSite("Foo", new MockAdapter());
        }
Ejemplo n.º 3
0
        public void UnregisterSiteCreatedInParentThrows()
        {
            UIExtensionSiteCollection parent = new UIExtensionSiteCollection();
            UIExtensionSiteCollection child  = new UIExtensionSiteCollection(parent);

            parent.RegisterSite("Foo", new MockAdapter());
            child.UnregisterSite("Foo");
        }
Ejemplo n.º 4
0
        public void CanCountSitesInCollection()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("Foo", new MockAdapter());

            Assert.AreEqual(1, collection.Count);
        }
Ejemplo n.º 5
0
        public void CanRetrieveSiteViaIndexer()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("Foo", new MockAdapter());

            Assert.IsNotNull(collection["Foo"]);
        }
Ejemplo n.º 6
0
        public void CanUnregisterSiteCreatedWithAdapter()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("foo", new MockAdapter());
            collection.UnregisterSite("foo");

            Assert.IsFalse(collection.Contains("foo"));
        }
Ejemplo n.º 7
0
        public void CanFindOutIfSiteIsContainedInCollection()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("Foo", new MockAdapter());

            Assert.IsTrue(collection.Contains("Foo"));
            Assert.IsFalse(collection.Contains("Foo2"));
        }
Ejemplo n.º 8
0
        public void ContainsChecksParent()
        {
            UIExtensionSiteCollection parent = new UIExtensionSiteCollection();
            UIExtensionSiteCollection child  = new UIExtensionSiteCollection(parent);

            parent.RegisterSite("Foo", new MockAdapter());

            Assert.IsTrue(child.Contains("Foo"));
        }
Ejemplo n.º 9
0
        public void CountDoesNotIncludeDuplicates()
        {
            UIExtensionSiteCollection parent = new UIExtensionSiteCollection();
            UIExtensionSiteCollection child  = new UIExtensionSiteCollection(parent);

            parent.RegisterSite("Foo", new MockAdapter());
            UIExtensionSite childSite = child["Foo"];

            Assert.AreEqual(1, child.Count);
        }
Ejemplo n.º 10
0
        public void CountIncludesParentSites()
        {
            UIExtensionSiteCollection parent = new UIExtensionSiteCollection();
            UIExtensionSiteCollection child  = new UIExtensionSiteCollection(parent);

            parent.RegisterSite("Foo", new MockAdapter());
            child.RegisterSite("Bar", new MockAdapter());

            Assert.AreEqual(1, parent.Count);
            Assert.AreEqual(2, child.Count);
        }
Ejemplo n.º 11
0
        public void CanRegisterAdapterForSiteAndItIsUsedWithinTheSite()
        {
            MockAdapter adapter = new MockAdapter();
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();
            object obj = new object();

            collection.RegisterSite("Foo", adapter);
            collection["Foo"].Add(obj);

            Assert.AreSame(obj, adapter.AddedElement);
        }
Ejemplo n.º 12
0
        public void CanRetrieveParentSiteViaIndexer()
        {
            UIExtensionSiteCollection parent = new UIExtensionSiteCollection();
            UIExtensionSiteCollection child  = new UIExtensionSiteCollection(parent);

            parent.RegisterSite("Foo", new MockAdapter());
            child.RegisterSite("Bar", new MockAdapter());

            Assert.IsNotNull(child["Foo"]);
            Assert.IsNotNull(child["Bar"]);
        }
Ejemplo n.º 13
0
        public void CanUnregisterSiteCreatedWithObject()
        {
            TestableRootWorkItem wi = new TestableRootWorkItem();

            wi.Services.Remove <IUIElementAdapterFactoryCatalog>();
            wi.Services.AddNew <MockFactoryCatalog, IUIElementAdapterFactoryCatalog>();
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection(wi);

            collection.RegisterSite("foo", new object());
            collection.UnregisterSite("foo");

            Assert.IsFalse(collection.Contains("foo"));
        }
Ejemplo n.º 14
0
        public void CanRegisterSiteFromObjectAndFactoryCatalogIsUsed()
        {
            TestableRootWorkItem wi = new TestableRootWorkItem();

            wi.Services.Remove <IUIElementAdapterFactoryCatalog>();
            MockFactoryCatalog        factoryCatalog = wi.Services.AddNew <MockFactoryCatalog, IUIElementAdapterFactoryCatalog>();
            UIExtensionSiteCollection collection     = new UIExtensionSiteCollection(wi);
            object obj = new object();

            collection.RegisterSite("Foo", new object());
            collection["Foo"].Add(obj);

            Assert.AreSame(obj, factoryCatalog.Adapter.AddedElement);
        }
Ejemplo n.º 15
0
        public void ItemsAddedToLocalSiteDoNotAffectItemsInParentSite()
        {
            UIExtensionSiteCollection parent = new UIExtensionSiteCollection();
            UIExtensionSiteCollection child  = new UIExtensionSiteCollection(parent);

            parent.RegisterSite("Foo", new MockAdapter());

            UIExtensionSite parentSite = parent["Foo"];
            UIExtensionSite childSite  = child["Foo"];

            parentSite.Add(new object());
            childSite.Add(new object());

            Assert.AreEqual(1, parentSite.Count);
            Assert.AreEqual(1, childSite.Count);
        }
Ejemplo n.º 16
0
        public void InvalidSiteNameThrows()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            UIExtensionSite unused = collection["Foo"];
        }
Ejemplo n.º 17
0
        public void NullObjectThrows()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("Foo", (object)null);
        }
Ejemplo n.º 18
0
        public void EmptySiteNameWithObjectThrows()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("", new object());
        }
Ejemplo n.º 19
0
        public void NullAdapterThrows()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("Foo", (IUIElementAdapter)null);
        }
Ejemplo n.º 20
0
        public void EmptySiteNameWithAdapterThrows()
        {
            UIExtensionSiteCollection collection = new UIExtensionSiteCollection();

            collection.RegisterSite("", new MockAdapter());
        }