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); }
/// <inheritdoc/> protected override void AddAccessPointsInternal(AppEntry appEntry, Feed feed, IEnumerable <AccessPoint> accessPoints) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException("appEntry"); } if (feed == null) { throw new ArgumentNullException("feed"); } if (accessPoints == null) { throw new ArgumentNullException("accessPoints"); } if (appEntry.AccessPoints != null && appEntry.AccessPoints.Entries == accessPoints) { throw new ArgumentException("Must not be equal to appEntry.AccessPoints.Entries", "accessPoints"); } #endregion // Skip entries with mismatching hostname if (appEntry.Hostname != null && !Regex.IsMatch(Environment.MachineName, appEntry.Hostname)) { return; } if (appEntry.AccessPoints == null) { appEntry.AccessPoints = new AccessPointList(); } AppList.CheckForConflicts(accessPoints, appEntry); accessPoints.ApplyWithRollback( accessPoint => accessPoint.Apply(appEntry, feed, Handler, 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)); }