Inheritance: XmlUnknown, ICloneable
コード例 #1
0
        public void TestAddAccessPoints()
        {
            var capabilityList = CapabilityListTest.CreateTestCapabilityList();
            var feed1 = new Feed {Name = "Test", CapabilityLists = {capabilityList}};
            var feed2 = new Feed {Name = "Test", CapabilityLists = {capabilityList}};
            using (var applyFlag1 = new TemporaryFlagFile("0install-unit-tests"))
            using (var applyFlag2 = new TemporaryFlagFile("0install-unit-tests"))
            {
                var accessPoints1 = new AccessPoint[] {new MockAccessPoint {ID = "id1", Capability = "my_ext1", ApplyFlagPath = applyFlag1}};
                var accessPoints2 = new AccessPoint[] {new MockAccessPoint {ID = "id2", Capability = "my_ext2", ApplyFlagPath = applyFlag2}};

                Assert.AreEqual(0, _integrationManager.AppList.Entries.Count);
                var appEntry1 = _integrationManager.AddApp(new FeedTarget(FeedTest.Test1Uri, feed1));
                _integrationManager.AddAccessPoints(appEntry1, feed1, accessPoints1);
                Assert.AreEqual(1, _integrationManager.AppList.Entries.Count, "Should implicitly create missing AppEntries");
                Assert.IsTrue(applyFlag1.Set, "Should apply AccessPoint");
                applyFlag1.Set = false;

                Assert.DoesNotThrow(() => _integrationManager.AddAccessPoints(appEntry1, feed1, accessPoints1), "Duplicate access points should be silently reapplied");
                Assert.IsTrue(applyFlag1.Set, "Duplicate access points should be silently reapplied");

                _integrationManager.AddAccessPoints(appEntry1, feed1, accessPoints2);
                applyFlag2.Set = false;

                var appEntry2 = _integrationManager.AddApp(new FeedTarget(FeedTest.Test2Uri, feed2));
                Assert.Throws<ConflictException>(() => _integrationManager.AddAccessPoints(appEntry2, feed2, accessPoints2), "Should prevent access point conflicts");
                Assert.IsFalse(applyFlag2.Set, "Should prevent access point conflicts");
            }
        }
コード例 #2
0
        public void AccessPointCandidatesInternalConflict()
        {
            var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "a"}, new MockAccessPoint {ID = "a"}};
            var appEntry = new AppEntry {Name = "App"};

            Assert.Throws<ConflictException>(() => accessPoints.GetConflictData(appEntry));
        }
コード例 #3
0
        public void AccessPointCandidates()
        {
            var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "a"}, new MockAccessPoint {ID = "b"}};
            var appEntry = new AppEntry {Name = "App"};

            accessPoints.GetConflictData(appEntry).Should().Equal(new Dictionary<string, ConflictData>()
            {
                {"mock:a", new ConflictData(accessPoints[0], appEntry)},
                {"mock:b", new ConflictData(accessPoints[1], appEntry)}
            });
        }
コード例 #4
0
        public void AccessPointCandidates()
        {
            var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "a"}, new MockAccessPoint {ID = "b"}};
            var appEntry = new AppEntry {Name = "App"};

            CollectionAssert.AreEqual(
                expected: new[]
                {
                    new KeyValuePair<string, ConflictData>("mock:a", new ConflictData(accessPoints[0], appEntry)),
                    new KeyValuePair<string, ConflictData>("mock:b", new ConflictData(accessPoints[1], appEntry))
                },
                actual: accessPoints.GetConflictData(appEntry));
        }
コード例 #5
0
        public void AccessPointCandidatesInternalConflict()
        {
            var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "a"}, new MockAccessPoint {ID = "a"}};
            var appEntry = new AppEntry {Name = "App"};

            accessPoints.Invoking(x => x.GetConflictData(appEntry)).ShouldThrow<ConflictException>();
        }
コード例 #6
0
        public void TestUpdateApp()
        {
            var capabilitiyList = new CapabilityList
            {
                OS = Architecture.CurrentSystem.OS,
                Entries = {new FileType {ID = "my_ext1"}, new FileType {ID = "my_ext2"}}
            };
            var feed = new Feed {Name = "Test 1", CapabilityLists = {capabilitiyList}};
            var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "id1", Capability = "my_ext1"}};

            var appEntry = _integrationManager.AddApp(new FeedTarget(FeedTest.Test1Uri, feed));
            _integrationManager.AddAccessPoints(appEntry, feed, accessPoints);
            CollectionAssert.AreEquivalent(accessPoints, _integrationManager.AppList.Entries[0].AccessPoints.Entries, "All access points should be applied.");

            // Modify feed
            feed.Name = "Test 2";
            capabilitiyList.Entries.RemoveLast();

            _integrationManager.UpdateApp(appEntry, feed);
            Assert.AreEqual("Test 2", appEntry.Name);
            CollectionAssert.AreEquivalent(new[] {accessPoints[0]}, _integrationManager.AppList.Entries[0].AccessPoints.Entries, "Only the first access point should be left.");
        }
コード例 #7
0
        public void TestAddAccessPoints()
        {
            var capabilityList = CapabilityListTest.CreateTestCapabilityList();
            var feed1 = new Feed {Name = "Test", CapabilityLists = {capabilityList}};
            var feed2 = new Feed {Name = "Test", CapabilityLists = {capabilityList}};
            using (var applyFlag1 = new TemporaryFlagFile("0install-unit-tests"))
            using (var applyFlag2 = new TemporaryFlagFile("0install-unit-tests"))
            {
                var accessPoints1 = new AccessPoint[] {new MockAccessPoint {ID = "id1", Capability = "my_ext1", ApplyFlagPath = applyFlag1}};
                var accessPoints2 = new AccessPoint[] {new MockAccessPoint {ID = "id2", Capability = "my_ext2", ApplyFlagPath = applyFlag2}};

                _integrationManager.AppList.Entries.Count.Should().Be(0);
                var appEntry1 = _integrationManager.AddApp(new FeedTarget(FeedTest.Test1Uri, feed1));
                _integrationManager.AddAccessPoints(appEntry1, feed1, accessPoints1);
                _integrationManager.AppList.Entries.Count.Should().Be(1, because: "Should implicitly create missing AppEntries");
                applyFlag1.Set.Should().BeTrue(because: "Should apply AccessPoint");
                applyFlag1.Set = false;

                _integrationManager.Invoking(x => x.AddAccessPoints(appEntry1, feed1, accessPoints1))
                    .ShouldNotThrow(because: "Duplicate access points should be silently reapplied");
                applyFlag1.Set.Should().BeTrue(because: "Duplicate access points should be silently reapplied");

                _integrationManager.AddAccessPoints(appEntry1, feed1, accessPoints2);
                applyFlag2.Set = false;

                var appEntry2 = _integrationManager.AddApp(new FeedTarget(FeedTest.Test2Uri, feed2));
                _integrationManager.Invoking(x => x.AddAccessPoints(appEntry2, feed2, accessPoints2))
                    .ShouldThrow<ConflictException>(because: "Should prevent access point conflicts");
                applyFlag2.Set.Should().BeFalse(because: "Should prevent access point conflicts");
            }
        }