public void SmallerThanOperatorWithFirstObjectSmaller() { var first = new DatasetId(9); var second = new DatasetId(10); Assert.IsTrue(first < second); }
public void Clone() { var first = new DatasetId(10); var second = first.Clone(); Assert.AreEqual(first, second); }
public void SmallerThanOperatorWithEqualObjects() { var first = new DatasetId(10); var second = new DatasetId(10); Assert.IsFalse(first < second); }
public void SmallerThanOperatorWithFirstObjectLarger() { var first = new DatasetId(11); var second = new DatasetId(10); Assert.IsFalse(first < second); }
public void SmallerThanOperatorWithSecondObjectNull() { var first = new DatasetId(10); DatasetId second = null; Assert.IsFalse(first < second); }
public void CompareToOperatorWithEqualObjects() { var first = new DatasetId(10); object second = new DatasetId(10); Assert.AreEqual(0, first.CompareTo(second)); }
public void LargerThanOperatorWithFirstObjectLarger() { var first = new DatasetId(11); var second = new DatasetId(10); Assert.IsTrue(first > second); }
public void SmallerThanOperatorWithFirstObjectNull() { DatasetId first = null; var second = new DatasetId(10); Assert.IsTrue(first < second); }
public void LargerThanOperatorWithFirstObjectNull() { DatasetId first = null; var second = new DatasetId(10); Assert.IsFalse(first > second); }
public void LargerThanOperatorWithSecondObjectNull() { var first = new DatasetId(10); DatasetId second = null; Assert.IsTrue(first > second); }
public void CompareToWithSmallerFirstObject() { var first = new DatasetId(10); object second = new DatasetId(11); Assert.IsTrue(first.CompareTo(second) < 0); }
public void Create() { var commandHub = new Mock <ISendCommandsToRemoteEndpoints>(); var id = new DatasetId(); var endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(); var networkId = NetworkIdentifier.ForLocalMachine(); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var notifications = new Mock <IDatasetApplicationNotifications>(); var notificationHub = new Mock <INotifyOfRemoteEndpointEvents>(); { notificationHub.Setup(n => n.HasNotificationsFor(It.IsAny <EndpointId>())) .Returns(true); notificationHub.Setup(n => n.NotificationsFor <IDatasetApplicationNotifications>(It.IsAny <EndpointId>())) .Callback <EndpointId>(e => Assert.AreSame(endpoint, e)) .Returns(notifications.Object); } var info = new DatasetOnlineInformation( id, endpoint, networkId, commandHub.Object, notificationHub.Object, systemDiagnostics); Assert.AreSame(id, info.Id); Assert.AreSame(endpoint, info.Endpoint); Assert.AreSame(networkId, info.RunsOn); }
public void CompareToWithUnequalObjectTypes() { var first = new DatasetId(10); object second = new object(); Assert.Throws <ArgumentException>(() => first.CompareTo(second)); }
public void CompareToWithNullObject() { var first = new DatasetId(10); object second = null; Assert.AreEqual(1, first.CompareTo(second)); }
public void SmallerThanOperatorWithBothObjectsNull() { DatasetId first = null; DatasetId second = null; Assert.IsFalse(first < second); }
public void AvailableCommands() { var id = new DatasetId(); var endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(); var networkId = NetworkIdentifier.ForLocalMachine(); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var commandList = new Dictionary <Type, ICommandSet> { { typeof(IMockCommandSetWithTaskReturn), new Mock <IMockCommandSetWithTaskReturn>().Object }, { typeof(IMockCommandSetWithTypedTaskReturn), new Mock <IMockCommandSetWithTaskReturn>().Object }, { typeof(IMockCommandSetForInternalUse), new Mock <IMockCommandSetWithTaskReturn>().Object }, }; var commandHub = new Mock <ISendCommandsToRemoteEndpoints>(); { commandHub.Setup(h => h.AvailableCommandsFor(It.IsAny <EndpointId>())) .Returns(commandList.Keys); commandHub.Setup(h => h.CommandsFor(It.IsAny <EndpointId>(), It.IsAny <Type>())) .Returns <EndpointId, Type>((e, t) => commandList[t]); } var notifications = new Mock <IDatasetApplicationNotifications>(); var notificationHub = new Mock <INotifyOfRemoteEndpointEvents>(); { notificationHub.Setup(n => n.HasNotificationsFor(It.IsAny <EndpointId>())) .Returns(true); notificationHub.Setup(n => n.NotificationsFor <IDatasetApplicationNotifications>(It.IsAny <EndpointId>())) .Callback <EndpointId>(e => Assert.AreSame(endpoint, e)) .Returns(notifications.Object); } var info = new DatasetOnlineInformation( id, endpoint, networkId, commandHub.Object, notificationHub.Object, systemDiagnostics); var commands = info.AvailableCommands(); Assert.AreEqual(2, commands.Count()); }
/// <summary> /// Initializes a new instance of the <see cref="DatasetOnlineInformation"/> class. /// </summary> /// <param name="id">The ID number of the dataset.</param> /// <param name="endpoint">The ID number of the endpoint that has the actual dataset loaded.</param> /// <param name="networkId">The network identifier of the machine on which the dataset runs.</param> /// <param name="commandHub">The object that handles sending commands to the remote endpoint.</param> /// <param name="notificationHub">The object that handles the event notifications for remote endpoints.</param> /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="id"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="endpoint"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="networkId"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="commandHub"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="notificationHub"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />. /// </exception> public DatasetOnlineInformation( DatasetId id, EndpointId endpoint, NetworkIdentifier networkId, ISendCommandsToRemoteEndpoints commandHub, INotifyOfRemoteEndpointEvents notificationHub, SystemDiagnostics systemDiagnostics) { { Enforce.Argument(() => id); Enforce.Argument(() => endpoint); Enforce.Argument(() => networkId); Enforce.Argument(() => commandHub); Enforce.Argument(() => notificationHub); Enforce.Argument(() => systemDiagnostics); } Id = id; Endpoint = endpoint; RunsOn = networkId; m_CommandHub = commandHub; m_Diagnostics = systemDiagnostics; m_NotificationHub = notificationHub; { Debug.Assert( m_NotificationHub.HasNotificationFor(Endpoint, typeof(IDatasetApplicationNotifications)), "Missing essential notification set."); var notifications = m_NotificationHub.NotificationsFor <IDatasetApplicationNotifications>(Endpoint); notifications.OnSwitchToEditingMode += (s, e) => { m_IsEditMode = true; RaiseOnSwitchToEditMode(); }; notifications.OnSwitchToExecutingMode += (s, e) => { m_IsEditMode = false; RaiseOnSwitchToExecutingMode(); }; notifications.OnTimelineUpdate += (s, e) => { RaiseOnTimelineUpdate(); }; } }
public void Close() { var id = new DatasetId(); var endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(); var networkId = NetworkIdentifier.ForLocalMachine(); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var datasetCommands = new Mock <IDatasetApplicationCommands>(); { datasetCommands.Setup(d => d.Close()) .Returns( Task.Factory.StartNew( () => { }, new CancellationToken(), TaskCreationOptions.None, new CurrentThreadTaskScheduler())) .Verifiable(); } var commandHub = new Mock <ISendCommandsToRemoteEndpoints>(); { commandHub.Setup(h => h.HasCommandFor(It.IsAny <EndpointId>(), It.IsAny <Type>())) .Returns(true); commandHub.Setup(h => h.CommandsFor <IDatasetApplicationCommands>(It.IsAny <EndpointId>())) .Returns(datasetCommands.Object); } var notifications = new Mock <IDatasetApplicationNotifications>(); var notificationHub = new Mock <INotifyOfRemoteEndpointEvents>(); { notificationHub.Setup(n => n.HasNotificationsFor(It.IsAny <EndpointId>())) .Returns(true); notificationHub.Setup(n => n.NotificationsFor <IDatasetApplicationNotifications>(It.IsAny <EndpointId>())) .Callback <EndpointId>(e => Assert.AreSame(endpoint, e)) .Returns(notifications.Object); } var info = new DatasetOnlineInformation( id, endpoint, networkId, commandHub.Object, notificationHub.Object, systemDiagnostics); info.Close(); datasetCommands.Verify(d => d.Close(), Times.Once()); }
public void Command() { var id = new DatasetId(); var endpoint = EndpointIdExtensions.CreateEndpointIdForCurrentProcess(); var networkId = NetworkIdentifier.ForLocalMachine(); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var commandList = new SortedList <Type, ICommandSet> { { typeof(IMockCommandSetWithTaskReturn), new Mock <IMockCommandSetWithTaskReturn>().Object }, }; var commandHub = new Mock <ISendCommandsToRemoteEndpoints>(); { commandHub.Setup(h => h.CommandsFor <IMockCommandSetWithTaskReturn>(It.IsAny <EndpointId>())) .Returns((IMockCommandSetWithTaskReturn)commandList.Values[0]); } var notifications = new Mock <IDatasetApplicationNotifications>(); var notificationHub = new Mock <INotifyOfRemoteEndpointEvents>(); { notificationHub.Setup(n => n.HasNotificationsFor(It.IsAny <EndpointId>())) .Returns(true); notificationHub.Setup(n => n.NotificationsFor <IDatasetApplicationNotifications>(It.IsAny <EndpointId>())) .Callback <EndpointId>(e => Assert.AreSame(endpoint, e)) .Returns(notifications.Object); } var info = new DatasetOnlineInformation( id, endpoint, networkId, commandHub.Object, notificationHub.Object, systemDiagnostics); var commands = info.Command <IMockCommandSetWithTaskReturn>(); Assert.AreSame(commandList.Values[0], commands); }
/// <summary> /// Initializes a new instance of the <see cref="DatasetCannotBecomeParentException"/> class. /// </summary> /// <param name="id">The ID number of the dataset that could not be made a parent.</param> public DatasetCannotBecomeParentException(DatasetId id) : this(string.Format(CultureInfo.InvariantCulture, Resources.Exceptions_Messages_DatasetCannotBecomeParent_WithId, id)) { }