public void TestRemoveAccessPoints() { var capabilityList = CapabilityListTest.CreateTestCapabilityList(); var testApp = new Feed { Name = "Test", CapabilityLists = { capabilityList } }; using var unapplyFlag = new TemporaryFlagFile("0install-unit-tests"); var accessPoint = new MockAccessPoint { ID = "id1", Capability = "my_ext1", UnapplyFlagPath = unapplyFlag }; // Inject access point into AppEntry (without running integration) var appEntry = _integrationManager.AddApp(new FeedTarget(FeedTest.Test1Uri, testApp)); appEntry.AccessPoints = new AccessPointList { Entries = { accessPoint } }; _integrationManager.RemoveAccessPoints(appEntry, new[] { accessPoint }); _integrationManager.AppList.Entries[0].AccessPoints !.Entries.Should().BeEmpty(); unapplyFlag.Set.Should().BeTrue(because: "Unapply() should be called"); _integrationManager.Invoking(x => x.RemoveAccessPoints(appEntry, new[] { accessPoint })) .Should().NotThrow(because: "Allow multiple removals of access points."); }
/// <summary> /// Creates a fictive test <see cref="Feed"/>. /// </summary> public static Feed CreateTestFeed() => new Feed { Uri = Test1Uri, Name = "MyApp", Categories = { "Category1", "Category2" }, Homepage = new Uri("http://example.com/"), Feeds = { new FeedReference { Source = Sub1Uri } }, FeedFor = { new InterfaceReference { Target = new FeedUri("http://example.com/super1.xml") } }, Summaries = { "Default summary", { "de-DE", "German summary" } }, Descriptions = { "Default description", { "de-DE", "German description" } }, Icons = { new Icon { Href = new Uri("http://example.com/test.png"), MimeType = Icon.MimeTypePng } }, Elements = { CreateTestImplementation(), CreateTestPackageImplementation(), CreateTestGroup() }, CapabilityLists = { CapabilityListTest.CreateTestCapabilityList() }, EntryPoints = { new EntryPoint { Command = Command.NameRun, BinaryName = "myapp", Names = { "Entry name", { "de-DE", "German entry name" } }, Summaries = { "Entry summary", { "de-DE", "German entry summary" } }, Icons = { new Icon { Href = new Uri("http://example.com/test_command.png"), MimeType = Icon.MimeTypePng } } } } };
public void TestAddApp() { var capabilityList = CapabilityListTest.CreateTestCapabilityList(); var target = new FeedTarget(FeedTest.Test1Uri, new Feed { Name = "Test", CapabilityLists = { capabilityList } }); _integrationManager.AddApp(target); _integrationManager.AppList.Entries .Should().Equal(new AppEntry { InterfaceUri = FeedTest.Test1Uri, Name = target.Feed.Name, CapabilityLists = { capabilityList } }); _integrationManager.Invoking(x => x.AddApp(target)) .Should().Throw <InvalidOperationException>(because: "Do not allow adding applications to AppList more than once."); }
public void TestAddApp() { var capabilityList = CapabilityListTest.CreateTestCapabilityList(); var target = new FeedTarget(FeedTest.Test1Uri, new Feed { Name = "Test", CapabilityLists = { capabilityList } }); _integrationManager.AddApp(target); var expectedAppEntry = new AppEntry { InterfaceUri = FeedTest.Test1Uri, Name = target.Feed.Name, CapabilityLists = { capabilityList } }; CollectionAssert.AreEqual(new[] { expectedAppEntry }, _integrationManager.AppList.Entries); Assert.Throws <InvalidOperationException>(() => _integrationManager.AddApp(target), "Do not allow adding applications to AppList more than once."); }
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)) .Should().NotThrow(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)) .Should().Throw <ConflictException>(because: "Should prevent access point conflicts"); applyFlag2.Set.Should().BeFalse(because: "Should prevent access point conflicts"); }
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"); } }