public void ChildNodeObjects_WithData_ReturnsChildrenWithContextAndDataReversed() { // Setup var chartData1 = new TestChartData(); var chartData2 = new TestChartData(); var chartData3 = new TestChartData(); var chartDataCollection = new ChartDataCollection("test data"); chartDataCollection.Add(chartData1); chartDataCollection.Add(chartData2); chartDataCollection.Add(chartData3); // Call object[] objects = info.ChildNodeObjects(chartDataCollection); // Assert var expectedChildren = new[] { new ChartDataContext(chartData3, chartDataCollection), new ChartDataContext(chartData2, chartDataCollection), new ChartDataContext(chartData1, chartDataCollection) }; CollectionAssert.AreEqual(expectedChildren, objects); }
public void OnDrop_ChartDataMovedToPositionInsideRange_SetsNewReverseOrder(int position) { // Setup var observer = mocks.StrictMock <IObserver>(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); var chartData1 = new TestChartData(); var chartData2 = new TestChartData(); var chartData3 = new TestChartData(); var chartDataCollection = new ChartDataCollection("test"); chartDataCollection.Add(chartData1); chartDataCollection.Add(chartData2); chartDataCollection.Add(chartData3); ChartDataContext context1 = GetContext(chartData1); ChartDataContext collectionContext = GetContext(chartDataCollection); chartDataCollection.Attach(observer); using (var treeViewControl = new TreeViewControl()) { // Call info.OnDrop(context1, collectionContext, collectionContext, position, treeViewControl); // Assert int reversedIndex = 2 - position; var wrappedCollectionData = (ChartDataCollection)collectionContext.WrappedData; Assert.AreSame(context1.WrappedData, wrappedCollectionData.Collection.ElementAt(reversedIndex)); } }
public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() { // Setup const int numberOfChangedProperties = 1; var mocks = new MockRepository(); var observer = mocks.StrictMock <IObserver>(); observer.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); mocks.ReplayAll(); var chartData = new TestChartData("Test"); chartData.Attach(observer); var properties = new TestChartDataProperties { Data = chartData }; // Call properties.IsVisible = false; // Assert Assert.IsFalse(chartData.IsVisible); mocks.VerifyAll(); }
public void ChildNodeObjects_ChartDataCollection_ReturnsItemsFromChartDataCollectionList() { // Setup var chartData1 = new TestChartData(); var chartData2 = new TestChartData(); var chartData3 = new TestChartData(); var chartDataCollection = new ChartDataCollection("test"); chartDataCollection.Add(chartData1); chartDataCollection.Add(chartData2); chartDataCollection.Add(chartData3); ChartDataContext context = GetContext(chartDataCollection); // Call object[] objects = info.ChildNodeObjects(context); // Assert var expectedChildren = new[] { new ChartDataContext(chartData3, new ChartDataCollection("test")), new ChartDataContext(chartData2, new ChartDataCollection("test")), new ChartDataContext(chartData1, new ChartDataCollection("test")) }; CollectionAssert.AreEqual(expectedChildren, objects); }
public void Create_OtherData_ThrowsNotSupportedException() { // Setup var testData = new TestChartData("test data"); // Call TestDelegate test = () => ChartDataSeriesFactory.Create(testData); // Assert Assert.Throws <NotSupportedException>(test); }
public void ParameteredConstructor_ExpectedValues() { // Setup const string name = "Some name"; // Call var data = new TestChartData(name); // Assert Assert.IsInstanceOf <Observable>(data); Assert.AreEqual(name, data.Name); Assert.IsTrue(data.IsVisible); }
public void ConvertSeriesProperties_TargetSeriesNull_ThrowsArgumentNullException() { // Setup var testConverter = new TestChartDataConverter(); var chartData = new TestChartData("test data"); // Call TestDelegate test = () => testConverter.ConvertSeriesProperties(chartData, null); // Assert const string expectedMessage = "Null data cannot be used as conversion target."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(test, expectedMessage); }
public void Name_InvalidName_ThrowsArgumentException(string invalidName) { // Setup const string name = "Some name"; var data = new TestChartData(name); // Call TestDelegate call = () => data.Name = invalidName; // Assert const string expectedMessage = "A name must be set to the chart data."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage); }
public void ConvertSeriesProperties_ChartData_NameSetToSeries() { // Setup const string name = "<Some name>"; var testConverter = new TestChartDataConverter(); var chartData = new TestChartData(name); var chartSeries = new TestSeries(); // Call testConverter.ConvertSeriesProperties(chartData, chartSeries); // Assert Assert.AreEqual(name, chartSeries.Title); }
public void CanDrop_TargetParentIsSameAsSourceParent_ReturnsTrue() { // Setup ChartData chartData = new TestChartData(); var chartDataCollection = new ChartDataCollection("test"); ChartDataContext context = GetContext(chartData, chartDataCollection); // Call bool canDrop = info.CanDrop(context, chartDataCollection); // Assert Assert.IsTrue(canDrop); }
public void Data_SetNewChartDataContextInstance_ReturnCorrectPropertyValues() { // Setup var chartData = new TestChartData("TestChart"); var properties = new TestChartDataProperties(); // Call properties.Data = chartData; // Assert Assert.AreEqual(chartData.Name, properties.Name); Assert.AreEqual(chartData.IsVisible, properties.IsVisible); Assert.AreEqual("Test type string", properties.Type); }
public void CanInsert_TargetParentNotSameAsSourceParent_ReturnsFalse() { // Setup ChartData chartData = new TestChartData(); var chartDataCollection = new ChartDataCollection("test"); ChartDataContext context = GetContext(chartData, chartDataCollection); // Call bool canInsert = info.CanInsert(context, GetContext(new ChartDataCollection("test"))); // Assert Assert.IsFalse(canInsert); }
public void CanInsert_TargetParentNotSameAsSourceParent_ReturnsFalse() { // Setup ChartData chartData = new TestChartData(); ChartData chartData2 = new TestChartData(); ChartDataContext context = GetContext(chartData); ChartDataContext targetContext = GetContext(chartData2); // Call bool canInsert = info.CanInsert(context, targetContext); // Assert Assert.IsFalse(canInsert); }
public void Insert_InvalidIndex_ThrowsArgumentOutOfRangeException(int invalidIndex) { // Setup var itemToInsert = new ChartLineData("test"); var existingItem = new TestChartData("test"); var chartDataCollection = new ChartDataCollection("test"); chartDataCollection.Add(existingItem); // Call TestDelegate call = () => chartDataCollection.Insert(invalidIndex, itemToInsert); // Assert Assert.Throws <ArgumentOutOfRangeException>(call, "index"); }
public void CanInsert_TargetDataIsCollection_ReturnsFalse() { // Setup ChartData chartData = new TestChartData(); var rootCollection = new ChartDataCollection("test"); var targetCollection = new ChartDataCollection("test"); ChartDataContext context = GetContext(chartData, rootCollection); ChartDataContext targetContext = GetContext(targetCollection, rootCollection); // Call bool canDrop = info.CanInsert(context, targetContext); // Assert Assert.IsFalse(canDrop); }
public void ConvertSeriesProperties_ChartData_IsVisibleSetToSeries(bool isVisible) { // Setup var testConverter = new TestChartDataConverter(); var chartData = new TestChartData("test data") { IsVisible = isVisible }; var chartSeries = new TestSeries(); // Call testConverter.ConvertSeriesProperties(chartData, chartSeries); // Assert Assert.AreEqual(isVisible, chartSeries.IsVisible); }
public void Constructor_ExpectedValues() { // Setup ChartData data = new TestChartData(); var collection = new ChartDataCollection("test"); collection.Add(data); // Call var context = new ChartDataContext(data, collection); // Assert Assert.IsInstanceOf <ObservableWrappedObjectContextBase <ChartData> >(context); Assert.AreSame(data, context.WrappedData); Assert.AreSame(collection, context.ParentChartData); }
public void Name_SetName_ReturnsNewName() { // Setup const string name = "Some name"; const string newName = "Something"; var data = new TestChartData(name); // Precondition Assert.AreEqual(name, data.Name); // Call data.Name = newName; // Assert Assert.AreNotEqual(name, data.Name); Assert.AreEqual(newName, data.Name); }
public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup var chartDataContext = new TestChartData("TestChart"); // Call var properties = new TestChartDataProperties { Data = chartDataContext }; // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(3, dynamicProperties.Count); const string generalCategory = "Algemeen"; PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "De naam van deze gegevensreeks.", true); PropertyDescriptor typeProperty = dynamicProperties[typePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(typeProperty, generalCategory, "Type", "Het type van de data die wordt weergegeven in de gegevensreeks.", true); PropertyDescriptor isVisibleProperty = dynamicProperties[visiblePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isVisibleProperty, generalCategory, "Weergeven", "Geeft aan of de gegevensreeks wordt weergegeven."); }
public void Insert_ItemNotNullAndValidIndex_InsertsItemToCollectionAtGivenIndex() { // Setup var itemToInsert = new ChartLineData("test"); var existingItem = new TestChartData("test"); var chartDataCollection = new ChartDataCollection("test"); chartDataCollection.Add(existingItem); // Precondition Assert.AreEqual(1, chartDataCollection.Collection.Count()); Assert.AreSame(existingItem, chartDataCollection.Collection.ElementAt(0)); // Call chartDataCollection.Insert(0, itemToInsert); // Assert Assert.AreEqual(2, chartDataCollection.Collection.Count()); Assert.AreSame(itemToInsert, chartDataCollection.Collection.ElementAt(0)); Assert.AreSame(existingItem, chartDataCollection.Collection.ElementAt(1)); }