public void NoConflicts() { var accessPointA = new MockAccessPoint { ID = "a" }; var appEntry1 = new AppEntry { Name = "App1", InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList { Entries = { accessPointA } } }; var accessPointB = new MockAccessPoint { ID = "b" }; var appEntry2 = new AppEntry { Name = "App2", InterfaceUri = FeedTest.Test2Uri }; var appList = new AppList { Entries = { appEntry1 } }; appList.CheckForConflicts(new[] { accessPointB }, appEntry2); }
public void ReApply() { var accessPointA = new MockAccessPoint {ID = "a"}; var appEntry1 = new AppEntry { Name = "App1", InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList {Entries = {accessPointA}} }; var appList = new AppList {Entries = {appEntry1}}; appList.CheckForConflicts(new[] {accessPointA}, appEntry1); }
/// <inheritdoc/> protected override void AddAccessPointsInternal(AppEntry appEntry, Feed feed, IReadOnlyCollection <AccessPoint> accessPoints) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } if (feed == null) { throw new ArgumentNullException(nameof(feed)); } if (accessPoints == null) { throw new ArgumentNullException(nameof(accessPoints)); } if (appEntry.AccessPoints != null && ReferenceEquals(appEntry.AccessPoints.Entries, accessPoints)) { throw new ArgumentException("Must not be equal to appEntry.AccessPoints.Entries", nameof(accessPoints)); } #endregion // Skip entries with mismatching hostname if (appEntry.Hostname != null && !Regex.IsMatch(Environment.MachineName, appEntry.Hostname)) { return; } appEntry.AccessPoints ??= new(); AppList.CheckForConflicts(accessPoints, appEntry); var iconStore = IconStores.DesktopIntegration(Config, Handler, MachineWide); // Pre-cache splash screen for later use by GUI feed.SplashScreens.GetIcon(Icon.MimeTypePng)?.To(iconStore.GetFresh); accessPoints.ApplyWithRollback( accessPoint => accessPoint.Apply(appEntry, feed, iconStore, MachineWide), accessPoint => { // Don't perform rollback if the access point was already applied previously and this was only a refresh if (!appEntry.AccessPoints.Entries.Contains(accessPoint)) { accessPoint.Unapply(appEntry, MachineWide); } }); appEntry.AccessPoints.Entries.RemoveRange(accessPoints); // Replace pre-existing entries appEntry.AccessPoints.Entries.AddRange(accessPoints); appEntry.Timestamp = DateTime.UtcNow; }
public void Conflict() { var accessPointA = new MockAccessPoint {ID = "a"}; var appEntry1 = new AppEntry { Name = "App1", InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList {Entries = {accessPointA}} }; var appEntry2 = new AppEntry {Name = "App2", InterfaceUri = FeedTest.Test2Uri}; var appList = new AppList {Entries = {appEntry1}}; Assert.Throws<ConflictException>(() => appList.CheckForConflicts(new[] {accessPointA}, appEntry2)); }
public void Conflict() { var accessPointA = new MockAccessPoint { ID = "a" }; var appEntry1 = new AppEntry { Name = "App1", InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList { Entries = { accessPointA } } }; var appEntry2 = new AppEntry { Name = "App2", InterfaceUri = FeedTest.Test2Uri }; var appList = new AppList { Entries = { appEntry1 } }; Assert.Throws <ConflictException>(() => appList.CheckForConflicts(new[] { accessPointA }, appEntry2)); }