public void AddChildWithPersistenceInformation() { DatasetCreationInformation creationInformation = null; var storage = new Mock <IPersistenceInformation>(); var child = CreateMockDataset(); var dataset = new Mock <IProxyDataset>(); { dataset.Setup(d => d.StoredAt) .Returns(new Mock <IPersistenceInformation>().Object); dataset.Setup(d => d.CreateNewChild(It.IsAny <DatasetCreationInformation>())) .Callback <DatasetCreationInformation>(d => creationInformation = d) .Returns(child); } var facade = new DatasetFacade(dataset.Object); var childFacade = facade.AddChild(storage.Object); Assert.AreEqual(new DatasetFacade(child), childFacade); Assert.IsFalse(creationInformation.CanBeAdopted); Assert.IsTrue(creationInformation.CanBecomeParent); Assert.IsTrue(creationInformation.CanBeCopied); Assert.IsTrue(creationInformation.CanBeDeleted); Assert.AreEqual(DatasetCreator.User, creationInformation.CreatedOnRequestOf); Assert.AreEqual(storage.Object, creationInformation.LoadFrom); }
public void EqualsWithUnequalObjectTypes() { var first = new DatasetFacade(CreateMockDataset()); var second = new object(); Assert.IsFalse(first.Equals(second)); }
public void EqualsWithNullObject() { var first = new DatasetFacade(CreateMockDataset()); object second = null; Assert.IsFalse(first.Equals(second)); }
public void AddChildWithNullPersistenceInformation() { var dataset = new Mock <IProxyDataset>(); var facade = new DatasetFacade(dataset.Object); Assert.Throws <ArgumentNullException>(() => facade.AddChild(null)); }
public void EqualsWithEqualObjects() { var dataset = CreateMockDataset(); var first = new DatasetFacade(dataset); object second = new DatasetFacade(dataset); Assert.IsTrue(first.Equals(second)); }
public void DeleteWithUndeletableDataset() { var dataset = new Mock <IProxyDataset>(); { dataset.Setup(d => d.CanBeDeleted) .Returns(false); } var facade = new DatasetFacade(dataset.Object); Assert.Throws <CannotDeleteDatasetException>(() => facade.Delete()); }
public void OnDeactivated() { var dataset = new Mock <IProxyDataset>(); var facade = new DatasetFacade(dataset.Object); bool wasUnloaded = false; facade.OnDeactivated += (s, e) => wasUnloaded = true; dataset.Raise(d => d.OnDeactivated += null, EventArgs.Empty); Assert.IsTrue(wasUnloaded); }
public void OnSummaryUpdate() { var dataset = new Mock <IProxyDataset>(); var facade = new DatasetFacade(dataset.Object); bool eventRaised = false; facade.OnSummaryChanged += (s, e) => { eventRaised = true; }; dataset.Raise(d => d.OnSummaryChanged += null, new ValueChangedEventArgs <string>("newSummary")); Assert.IsTrue(eventRaised); }
public void Summary() { var dataset = new Mock <IProxyDataset>(); { dataset.SetupProperty(p => p.Summary); } var facade = new DatasetFacade(dataset.Object); var summary = "text"; facade.Summary = summary; Assert.AreEqual(summary, facade.Summary); }
public void Name() { var dataset = new Mock <IProxyDataset>(); { dataset.SetupProperty(p => p.Name); } var facade = new DatasetFacade(dataset.Object); var name = "name"; facade.Name = name; Assert.AreEqual(name, facade.Name); }
public void ChildrenOf() { var child = CreateMockDataset(); var dataset = new Mock <IProxyDataset>(); { dataset.Setup(d => d.Children()) .Returns(new List <IProxyDataset> { child }); } var facade = new DatasetFacade(dataset.Object); var children = facade.Children(); Assert.AreEqual(1, children.Count()); Assert.AreEqual(new DatasetFacade(child), children.First()); }
public void Delete() { var dataset = new Mock <IProxyDataset>(); { dataset.Setup(d => d.CanBeDeleted) .Returns(true); dataset.Setup(d => d.Delete()) .Verifiable(); } var facade = new DatasetFacade(dataset.Object); facade.Delete(); dataset.Verify(d => d.Delete(), Times.Once()); }
public void Create() { var dataset = new Mock <IProxyDataset>(); { dataset.Setup(d => d.CanBeAdopted) .Returns(true); dataset.Setup(d => d.CanBecomeParent) .Returns(true); dataset.Setup(d => d.CanBeCopied) .Returns(true); dataset.Setup(d => d.CanBeDeleted) .Returns(true); dataset.Setup(d => d.IsActivated) .Returns(true); dataset.Setup(d => d.IsValid) .Returns(true); dataset.Setup(d => d.CreatedBy) .Returns(DatasetCreator.User); } var facade = new DatasetFacade(dataset.Object); Assert.IsTrue(facade.IsValid); Assert.AreEqual(dataset.Object.CanBeAdopted, facade.CanBeAdopted); Assert.AreEqual(dataset.Object.CanBecomeParent, facade.CanBecomeParent); Assert.AreEqual(dataset.Object.CanBeCopied, facade.CanBeCopied); Assert.AreEqual(dataset.Object.CanBeDeleted, facade.CanBeDeleted); Assert.AreEqual(dataset.Object.IsActivated, facade.IsActivated); Assert.AreEqual(dataset.Object.CreatedBy, facade.CreatedBy); }