using System; using System.ComponentModel; using Core.Common.Controls.Charting; using Core.Common.Gui; using Core.Common.Utils.PropertyBag; using Core.Plugins.Charting.Property; using NUnit.Framework; using Rhino.Mocks; namespace Core.Plugins.Charting.Test.Property { [TestFixture] public class ChartSeriesPropertiesTest { [Test] public void DefaultConstructor_ExpectedValues() { // Call var properties = new ChartSeriesProperties(); // Assert Assert.IsInstanceOf>(properties); Assert.IsNull(properties.Data); } [Test] public void GetProperties_WithData_ReturnExpectedValues() { // Setup var mocks = new MockRepository(); var showInLegend = false; var title = "some title"; var verticalAxis = new VerticalAxis(); var chartSeries = mocks.StrictMock(); chartSeries.Expect(a => a.ShowInLegend).Return(showInLegend); chartSeries.Expect(a => a.Title).Return(title); chartSeries.Expect(a => a.VertAxis).Return(verticalAxis); mocks.ReplayAll(); var properties = new ChartSeriesProperties { Data = chartSeries }; // Call & Assert Assert.AreEqual(showInLegend, properties.ShowInLegend); Assert.AreEqual(title, properties.Title); Assert.AreEqual(verticalAxis, properties.VerticalAxis); mocks.VerifyAll(); } [Test] public void SetProperties_WithData_CallsSetters() { // Setup var mocks = new MockRepository(); var chartSeries = mocks.StrictMock(); var showInLegend = false; var title = "some title"; var verticalAxis = new VerticalAxis(); chartSeries.Expect(a => a.ShowInLegend).SetPropertyWithArgument(showInLegend); chartSeries.Expect(a => a.Title).SetPropertyWithArgument(title); chartSeries.Expect(a => a.VertAxis).SetPropertyWithArgument(verticalAxis); mocks.ReplayAll(); // Call new ChartSeriesProperties { Data = chartSeries, ShowInLegend = showInLegend, Title = title, VerticalAxis = verticalAxis }; // Assert mocks.VerifyAll(); } [Test] public void GetProperties_Always_ReturnsThreeProperties() { // Setup var mocks = new MockRepository(); var data = mocks.Stub(); mocks.ReplayAll(); var bag = new DynamicPropertyBag(new ChartSeriesProperties { Data = data }); // Call var properties = bag.GetProperties(new Attribute[] { new BrowsableAttribute(true) }); // Assert Assert.AreEqual(3, properties.Count); } } }