public void Create() { ITimeline timeline = null; timeline = new Timeline(t => BuildStorage(timeline, t)); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var offline = new Mock<IDatasetOfflineInformation>(); var plan = new DistributionPlan( (p, t, r) => new Task<DatasetOnlineInformation>( () => new DatasetOnlineInformation( new DatasetId(), new EndpointId("id"), new NetworkIdentifier("machine"), new Mock<ISendCommandsToRemoteEndpoints>().Object, new Mock<INotifyOfRemoteEndpointEvents>().Object, systemDiagnostics), t), offline.Object, new NetworkIdentifier("mymachine"), new DatasetActivationProposal()); Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>> distributor = (r, c) => new List<DistributionPlan> { plan }; var proxyLayer = new Mock<IProxyCompositionLayer>(); var project = new Project( timeline, distributor, d => new DatasetStorageProxy( d, new GroupSelector( new Mock<IConnectGroups>().Object, proxyLayer.Object), proxyLayer.Object), new Mock<ICollectNotifications>().Object, systemDiagnostics); Assert.IsNotNull(project); Assert.IsNotNull(project.BaseDataset()); }
public void ExportAfterClosing() { ITimeline timeline = null; timeline = new Timeline(t => BuildStorage(timeline, t)); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var offline = new Mock<IDatasetOfflineInformation>(); var plan = new DistributionPlan( (p, t, r) => Task<DatasetOnlineInformation>.Factory.StartNew( () => new DatasetOnlineInformation( new DatasetId(), new EndpointId("id"), new NetworkIdentifier("machine"), new Mock<ISendCommandsToRemoteEndpoints>().Object, new Mock<INotifyOfRemoteEndpointEvents>().Object, systemDiagnostics), t, TaskCreationOptions.None, new CurrentThreadTaskScheduler()), offline.Object, new NetworkIdentifier("mymachine"), new DatasetActivationProposal()); Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>> distributor = (r, c) => new List<DistributionPlan> { plan }; var proxyLayer = new Mock<IProxyCompositionLayer>(); var project = new Project( timeline, distributor, d => new DatasetStorageProxy( d, new GroupSelector( new Mock<IConnectGroups>().Object, proxyLayer.Object), proxyLayer.Object), new Mock<ICollectNotifications>().Object, systemDiagnostics); var dataset = project.BaseDataset(); project.Close(); Assert.Throws<CannotUseProjectAfterClosingItException>( () => project.Export(dataset.Id, false, new Mock<IPersistenceInformation>().Object)); }
public void Summary() { ITimeline timeline = null; timeline = new Timeline(t => BuildStorage(timeline, t)); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var offline = new Mock<IDatasetOfflineInformation>(); var plan = new DistributionPlan( (p, t, r) => Task<DatasetOnlineInformation>.Factory.StartNew( () => new DatasetOnlineInformation( new DatasetId(), new EndpointId("id"), new NetworkIdentifier("machine"), new Mock<ISendCommandsToRemoteEndpoints>().Object, new Mock<INotifyOfRemoteEndpointEvents>().Object, systemDiagnostics), t, TaskCreationOptions.None, new CurrentThreadTaskScheduler()), offline.Object, new NetworkIdentifier("mymachine"), new DatasetActivationProposal()); Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>> distributor = (r, c) => new List<DistributionPlan> { plan }; var proxyLayer = new Mock<IProxyCompositionLayer>(); var project = new Project( timeline, distributor, d => new DatasetStorageProxy( d, new GroupSelector( new Mock<IConnectGroups>().Object, proxyLayer.Object), proxyLayer.Object), new Mock<ICollectNotifications>().Object, systemDiagnostics); var summary = string.Empty; project.OnSummaryChanged += (s, e) => { summary = e.Value; }; project.Summary = "MyNewName"; Assert.AreEqual(project.Summary, summary); // Set the summary again, to the same thing. This // shouldn't notify summary = string.Empty; project.Summary = "MyNewName"; Assert.AreEqual(string.Empty, summary); }
public void RollForwardWithDeletesOnly() { ITimeline timeline = null; timeline = new Timeline(t => BuildStorage(timeline, t)); var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null); var offline = new Mock<IDatasetOfflineInformation>(); var plan = new DistributionPlan( (p, t, r) => Task<DatasetOnlineInformation>.Factory.StartNew( () => new DatasetOnlineInformation( new DatasetId(), new EndpointId("id"), new NetworkIdentifier("machine"), new Mock<ISendCommandsToRemoteEndpoints>().Object, new Mock<INotifyOfRemoteEndpointEvents>().Object, systemDiagnostics), t, TaskCreationOptions.None, new CurrentThreadTaskScheduler()), offline.Object, new NetworkIdentifier("mymachine"), new DatasetActivationProposal()); Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>> distributor = (r, c) => new List<DistributionPlan> { plan }; var proxyLayer = new Mock<IProxyCompositionLayer>(); var project = new Project( timeline, distributor, d => new DatasetStorageProxy( d, new GroupSelector( new Mock<IConnectGroups>().Object, proxyLayer.Object), proxyLayer.Object), new Mock<ICollectNotifications>().Object, systemDiagnostics); // Create a 'binary' tree of datasets. This should create the following tree: // X // / \ // / \ // / \ // / \ // / \ // X X // / \ / \ // / \ / \ // / \ / \ // X X X X // / \ / \ // X X X X var children = new List<DatasetId>(); var datasets = new Queue<IProxyDataset>(); var root = project.BaseDataset(); datasets.Enqueue(root); int count = 0; while (count < 10) { var creationInformation = new DatasetCreationInformation() { CreatedOnRequestOf = DatasetCreator.User, CanBecomeParent = true, CanBeAdopted = false, CanBeCopied = false, CanBeDeleted = true, LoadFrom = new Mock<IPersistenceInformation>().Object, }; var parent = datasets.Dequeue(); var newChildren = parent.CreateNewChildren(new DatasetCreationInformation[] { creationInformation, creationInformation }); foreach (var child in newChildren) { datasets.Enqueue(child); children.Add(child.Id); count++; } } var marks = new List<TimeMarker>(); marks.Add(project.History.Mark()); for (int i = children.Count - 1; i > -1; i--) { var child = project.Dataset(children[i]); child.Delete(); marks.Add(project.History.Mark()); } project.History.RollBackTo(marks[0]); for (int i = 1; i < marks.Count; i++) { project.History.RollForwardTo(marks[i]); Assert.AreEqual(children.Count - i + 1, project.NumberOfDatasets); for (int j = 0; j < children.Count; j++) { var child = project.Dataset(children[j]); if (j < children.Count - i) { Assert.IsTrue(child.IsValid); } else { Assert.IsNull(child); } } } }