Index: Core/Plugins/src/Core.Plugins.CommonTools.Gui/Property/ProjectProperties.cs =================================================================== diff -u -r62bda0a2744de5708f3cea188d90839e06908cc0 -r261638422bd5d4f04f8f4cc9862d2c0a8e83c500 --- Core/Plugins/src/Core.Plugins.CommonTools.Gui/Property/ProjectProperties.cs (.../ProjectProperties.cs) (revision 62bda0a2744de5708f3cea188d90839e06908cc0) +++ Core/Plugins/src/Core.Plugins.CommonTools.Gui/Property/ProjectProperties.cs (.../ProjectProperties.cs) (revision 261638422bd5d4f04f8f4cc9862d2c0a8e83c500) @@ -1,7 +1,10 @@ +using System.ComponentModel; +using System.Drawing; using Core.Common.Base.Data; using Core.Common.Gui; using Core.Common.Utils.Attributes; using Core.Plugins.CommonTools.Gui.Properties; +using Core.Plugins.CommonTools.Gui.Property.Charting; namespace Core.Plugins.CommonTools.Gui.Property { @@ -35,5 +38,18 @@ data.Description = value; } } + + [TypeConverter(typeof(ChartFontPropertiesConverter))] + public Font SomeFont + { + get + { + return new Font(FontFamily.GenericSansSerif, 12); + } + set + { + + } + } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/AreaChartSeriesPropertiesTest.cs =================================================================== diff -u -r62bda0a2744de5708f3cea188d90839e06908cc0 -r261638422bd5d4f04f8f4cc9862d2c0a8e83c500 --- Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/AreaChartSeriesPropertiesTest.cs (.../AreaChartSeriesPropertiesTest.cs) (revision 62bda0a2744de5708f3cea188d90839e06908cc0) +++ Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/AreaChartSeriesPropertiesTest.cs (.../AreaChartSeriesPropertiesTest.cs) (revision 261638422bd5d4f04f8f4cc9862d2c0a8e83c500) @@ -4,400 +4,150 @@ using Core.Common.Controls.Charting.Series; using Core.Plugins.CommonTools.Gui.Property.Charting; using NUnit.Framework; +using Rhino.Mocks; namespace Core.Plugins.CommonTools.Gui.Test.Property.Charting { [TestFixture] public class AreaChartSeriesPropertiesTest { [Test] - public void InterpolationType_WithData_SameAsData() + public void DefaultConstructor_ExpectedValues() { - // Setup - var someInterpolationType = InterpolationType.Constant; - var otherInterpolationType = InterpolationType.Linear; - - var chartSeries = new AreaChartSeries - { - InterpolationType = someInterpolationType - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someInterpolationType, properties.InterpolationType); - // Call - properties.InterpolationType = otherInterpolationType; + var properties = new AreaChartSeriesProperties(); // Assert - Assert.AreEqual(otherInterpolationType, chartSeries.InterpolationType); + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); } [Test] - public void Color_WithData_SameAsData() + public void GetProperties_WithData_ReturnExpectedValues() { // Setup - var someColor = Color.AliceBlue; - var otherColor = Color.AntiqueWhite; - - var chartSeries = new AreaChartSeries - { - Color = someColor - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someColor, properties.Color); - - // Call - properties.Color = otherColor; - - // Assert - Assert.AreEqual(otherColor, chartSeries.Color); - } - - [Test] - public void Transparency_WithData_SameAsData() - { - // Setup + var someInterpolationType = InterpolationType.Constant; + var someColor = Color.FromArgb(255, 240, 240, 222); // Using Color constant fails, probably due to how Area.Color works (in AreaChartSeries.Color). var someTransparency = 0; - var otherTransparency = 1; - - var chartSeries = new AreaChartSeries - { - Transparency = someTransparency - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someTransparency, properties.Transparency); - - // Call - properties.Transparency = otherTransparency; - - // Assert - Assert.AreEqual(otherTransparency, chartSeries.Transparency); - } - - [Test] - public void UseHatch_WithData_SameAsData() - { - // Setup - var someHatch = false; - var otherHatch = true; - - var chartSeries = new AreaChartSeries - { - UseHatch = someHatch - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someHatch, properties.UseHatch); - - // Call - properties.UseHatch = otherHatch; - - // Assert - Assert.AreEqual(otherHatch, chartSeries.UseHatch); - } - - [Test] - public void HatchStyle_WithData_SameAsData() - { - // Setup + var someUseHatch = false; var someHatchStyle = HatchStyle.BackwardDiagonal; - var otherHatchStyle = HatchStyle.Cross; - - var chartSeries = new AreaChartSeries - { - HatchStyle = someHatchStyle - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someHatchStyle, properties.HatchStyle); - - // Call - properties.HatchStyle = otherHatchStyle; - - // Assert - Assert.AreEqual(otherHatchStyle, chartSeries.HatchStyle); - } - - [Test] - public void HatchColor_WithData_SameAsData() - { - // Setup var someHatchColor = Color.AliceBlue; - var otherHatchColor = Color.AntiqueWhite; - - var chartSeries = new AreaChartSeries - { - HatchColor = someHatchColor - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someHatchColor, properties.HatchColor); - - // Call - properties.HatchColor = otherHatchColor; - - // Assert - Assert.AreEqual(otherHatchColor, chartSeries.HatchColor); - } - - [Test] - public void LineColor_WithData_SameAsData() - { - // Setup var someLineColor = Color.AliceBlue; - var otherLineColor = Color.AntiqueWhite; - - var chartSeries = new AreaChartSeries - { - LineColor = someLineColor - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someLineColor, properties.LineColor); - - // Call - properties.LineColor = otherLineColor; - - // Assert - Assert.AreEqual(otherLineColor, chartSeries.LineColor); - } - - [Test] - public void LineWidth_WithData_SameAsData() - { - // Setup var someLineWidth = 2; - var otherLineWidth = 3; - - var chartSeries = new AreaChartSeries - { - LineWidth = someLineWidth - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someLineWidth, properties.LineWidth); - - // Call - properties.LineWidth = otherLineWidth; - - // Assert - Assert.AreEqual(otherLineWidth, chartSeries.LineWidth); - } - - [Test] - public void LineVisible_WithData_SameAsData() - { - // Setup var someLineVisible = false; - var otherLineVisible = true; - - var chartSeries = new AreaChartSeries - { - LineVisible = someLineVisible - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(someLineVisible, properties.LineVisible); - - // Call - properties.LineVisible = otherLineVisible; - - // Assert - Assert.AreEqual(otherLineVisible, chartSeries.LineVisible); - } - - [Test] - public void PointerColor_WithData_SameAsData() - { - // Setup var somePointerColor = Color.AliceBlue; - var otherPointerColor = Color.AntiqueWhite; - - var chartSeries = new AreaChartSeries - { - PointerColor = somePointerColor - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert - Assert.AreEqual(somePointerColor, properties.PointerColor); - - // Call - properties.PointerColor = otherPointerColor; - - // Assert - Assert.AreEqual(otherPointerColor, chartSeries.PointerColor); - } - - [Test] - public void PointerStyle_WithData_SameAsData() - { - // Setup var somePointerStyle = PointerStyles.Circle; - var otherPointerStyle = PointerStyles.Diamond; + var somePointerVisible = false; + var somePointerSize = 2; + var somePointerLineColor = Color.AliceBlue; + var somePointerLineVisible = false; var chartSeries = new AreaChartSeries { - PointerStyle = somePointerStyle + InterpolationType = someInterpolationType, + Color = someColor, + Transparency = someTransparency, + UseHatch = someUseHatch, + HatchStyle = someHatchStyle, + HatchColor = someHatchColor, + LineColor = someLineColor, + LineWidth = someLineWidth, + LineVisible = someLineVisible, + PointerColor = somePointerColor, + PointerStyle = somePointerStyle, + PointerVisible = somePointerVisible, + PointerSize = somePointerSize, + PointerLineColor = somePointerLineColor, + PointerLineVisible = somePointerLineVisible }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - // Call & Assert - Assert.AreEqual(somePointerStyle, properties.PointerStyle); - - // Call - properties.PointerStyle = otherPointerStyle; - - // Assert - Assert.AreEqual(otherPointerStyle, chartSeries.PointerStyle); - } - - [Test] - public void PointerVisible_WithData_SameAsData() - { - // Setup - var somePointerVisible = true; - var otherPointerVisible = false; - - var chartSeries = new AreaChartSeries - { - PointerVisible = somePointerVisible - }; var properties = new AreaChartSeriesProperties { Data = chartSeries }; // Call & Assert + Assert.AreEqual(someInterpolationType, properties.InterpolationType); + Assert.AreEqual(someColor, properties.Color); + Assert.AreEqual(someTransparency, properties.Transparency); + Assert.AreEqual(someUseHatch, properties.UseHatch); + Assert.AreEqual(someHatchStyle, properties.HatchStyle); + Assert.AreEqual(someHatchColor, properties.HatchColor); + Assert.AreEqual(someLineColor, properties.LineColor); + Assert.AreEqual(someLineWidth, properties.LineWidth); + Assert.AreEqual(someLineVisible, properties.LineVisible); + Assert.AreEqual(somePointerColor, properties.PointerColor); + Assert.AreEqual(somePointerStyle, properties.PointerStyle); Assert.AreEqual(somePointerVisible, properties.PointerVisible); - - // Call - properties.PointerVisible = otherPointerVisible; - - // Assert - Assert.AreEqual(otherPointerVisible, chartSeries.PointerVisible); - } - - [Test] - public void PointerSize_WithData_SameAsData() - { - // Setup - var somePointerSize = 2; - var otherPointerSize = 3; - - var chartSeries = new AreaChartSeries - { - PointerSize = somePointerSize - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - - // Call & Assert Assert.AreEqual(somePointerSize, properties.PointerSize); - - // Call - properties.PointerSize = otherPointerSize; - - // Assert - Assert.AreEqual(otherPointerSize, chartSeries.PointerSize); + Assert.AreEqual(somePointerLineColor, properties.PointerLineColor); + Assert.AreEqual(somePointerLineVisible, properties.PointerLineVisible); } [Test] - public void PointerLineColor_WithData_SameAsData() + public void SetProperties_WithData_CallsSetters() { // Setup + var mocks = new MockRepository(); + var chartSeries = mocks.StrictMock(); + + var someInterpolationType = InterpolationType.Constant; + var someColor = Color.FromArgb(255, 240, 240, 222); // Using Color constant fails, probably due to how Area.Color works (in AreaChartSeries.Color). + var someTransparency = 0; + var someUseHatch = false; + var someHatchStyle = HatchStyle.BackwardDiagonal; + var someHatchColor = Color.AliceBlue; + var someLineColor = Color.AliceBlue; + var someLineWidth = 2; + var someLineVisible = false; + var somePointerColor = Color.AliceBlue; + var somePointerStyle = PointerStyles.Circle; + var somePointerVisible = false; + var somePointerSize = 2; var somePointerLineColor = Color.AliceBlue; - var otherPointerLineColor = Color.AntiqueWhite; + var somePointerLineVisible = false; - var chartSeries = new AreaChartSeries - { - PointerLineColor = somePointerLineColor - }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; + chartSeries.Expect(cs => cs.InterpolationType).SetPropertyWithArgument(someInterpolationType); + chartSeries.Expect(cs => cs.Color).SetPropertyWithArgument(someColor); + chartSeries.Expect(cs => cs.Transparency).SetPropertyWithArgument(someTransparency); + chartSeries.Expect(cs => cs.UseHatch).SetPropertyWithArgument(someUseHatch); + chartSeries.Expect(cs => cs.HatchStyle).SetPropertyWithArgument(someHatchStyle); + chartSeries.Expect(cs => cs.HatchColor).SetPropertyWithArgument(someHatchColor); + chartSeries.Expect(cs => cs.LineColor).SetPropertyWithArgument(someLineColor); + chartSeries.Expect(cs => cs.LineWidth).SetPropertyWithArgument(someLineWidth); + chartSeries.Expect(cs => cs.LineVisible).SetPropertyWithArgument(someLineVisible); + chartSeries.Expect(cs => cs.PointerColor).SetPropertyWithArgument(somePointerColor); + chartSeries.Expect(cs => cs.PointerStyle).SetPropertyWithArgument(somePointerStyle); + chartSeries.Expect(cs => cs.PointerVisible).SetPropertyWithArgument(somePointerVisible); + chartSeries.Expect(cs => cs.PointerSize).SetPropertyWithArgument(somePointerSize); + chartSeries.Expect(cs => cs.PointerLineColor).SetPropertyWithArgument(somePointerLineColor); + chartSeries.Expect(cs => cs.PointerLineVisible).SetPropertyWithArgument(somePointerLineVisible); - // Call & Assert - Assert.AreEqual(somePointerLineColor, properties.PointerLineColor); + mocks.ReplayAll(); // Call - properties.PointerLineColor = otherPointerLineColor; - - // Assert - Assert.AreEqual(otherPointerLineColor, chartSeries.PointerLineColor); - } - - [Test] - public void PointerLineVisible_WithData_SameAsData() - { - // Setup - var somePointerLineVisible = true; - var otherPointerLineVisible = false; - - var chartSeries = new AreaChartSeries + new AreaChartSeriesProperties { + Data = chartSeries, + InterpolationType = someInterpolationType, + Color = someColor, + Transparency = someTransparency, + UseHatch = someUseHatch, + HatchStyle = someHatchStyle, + HatchColor = someHatchColor, + LineColor = someLineColor, + LineWidth = someLineWidth, + LineVisible = someLineVisible, + PointerColor = somePointerColor, + PointerStyle = somePointerStyle, + PointerVisible = somePointerVisible, + PointerSize = somePointerSize, + PointerLineColor = somePointerLineColor, PointerLineVisible = somePointerLineVisible }; - var properties = new AreaChartSeriesProperties - { - Data = chartSeries - }; - // Call & Assert - Assert.AreEqual(somePointerLineVisible, properties.PointerLineVisible); - - // Call - properties.PointerLineVisible = otherPointerLineVisible; - // Assert - Assert.AreEqual(otherPointerLineVisible, chartSeries.PointerLineVisible); + mocks.VerifyAll(); } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/BarSeriesPropertiesTest.cs =================================================================== diff -u -r62bda0a2744de5708f3cea188d90839e06908cc0 -r261638422bd5d4f04f8f4cc9862d2c0a8e83c500 --- Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/BarSeriesPropertiesTest.cs (.../BarSeriesPropertiesTest.cs) (revision 62bda0a2744de5708f3cea188d90839e06908cc0) +++ Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/BarSeriesPropertiesTest.cs (.../BarSeriesPropertiesTest.cs) (revision 261638422bd5d4f04f8f4cc9862d2c0a8e83c500) @@ -10,6 +10,17 @@ public class BarSeriesPropertiesTest { [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new BarSeriesProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] public void Color_WithData_SameAsData() { // Setup Index: Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisDateTimePropertiesTest.cs =================================================================== diff -u -r62bda0a2744de5708f3cea188d90839e06908cc0 -r261638422bd5d4f04f8f4cc9862d2c0a8e83c500 --- Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisDateTimePropertiesTest.cs (.../ChartAxisDateTimePropertiesTest.cs) (revision 62bda0a2744de5708f3cea188d90839e06908cc0) +++ Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisDateTimePropertiesTest.cs (.../ChartAxisDateTimePropertiesTest.cs) (revision 261638422bd5d4f04f8f4cc9862d2c0a8e83c500) @@ -10,78 +10,59 @@ public class ChartAxisDateTimePropertiesTest { [Test] - public void Maximum_WithData_GetFromData() + public void Constructor_WithAxis_ExpectedValues() { - // Setup + // Call var mocks = new MockRepository(); var chartAxis = mocks.StrictMock(); - var oaDate = new Random(21).NextDouble(); - chartAxis.Expect(a => a.Maximum).Return(oaDate); - - mocks.ReplayAll(); - var properties = new ChartAxisDateTimeProperties(chartAxis); - // Call & Assert - Assert.AreEqual(DateTime.FromOADate(oaDate), properties.Maximum); - - mocks.VerifyAll(); - } - - [Test] - public void Maximum_WithData_SetToData() - { - // Setup - var mocks = new MockRepository(); - var dateTime = DateTime.Parse("2015/12/17"); - var chartAxis = mocks.StrictMock(); - chartAxis.Expect(a => a.Maximum).SetPropertyWithArgument(dateTime.ToOADate()); - - mocks.ReplayAll(); - - var properties = new ChartAxisDateTimeProperties(chartAxis); - - // Call - properties.Maximum = dateTime; - // Assert - mocks.VerifyAll(); + Assert.IsInstanceOf(properties); } [Test] - public void Minimum_WithData_GetFromData() + public void GetProperties_WithData_ReturnExpectedValues() { // Setup var mocks = new MockRepository(); + var random = new Random(21); + var maximum = random.NextDouble(); + var minimum = random.NextDouble(); var chartAxis = mocks.StrictMock(); - var oaDate = new Random(21).NextDouble(); - chartAxis.Expect(a => a.Minimum).Return(oaDate); + chartAxis.Expect(a => a.Maximum).Return(maximum); + chartAxis.Expect(a => a.Minimum).Return(minimum); mocks.ReplayAll(); var properties = new ChartAxisDateTimeProperties(chartAxis); // Call & Assert - Assert.AreEqual(DateTime.FromOADate(oaDate), properties.Minimum); + Assert.AreEqual(DateTime.FromOADate(maximum), properties.Maximum); + Assert.AreEqual(DateTime.FromOADate(minimum), properties.Minimum); mocks.VerifyAll(); } [Test] - public void Minimum_WithData_SetToData() + public void SetProperties_WithData_CallsSetters() { // Setup var mocks = new MockRepository(); - var dateTime = DateTime.Parse("2015/12/17"); var chartAxis = mocks.StrictMock(); - chartAxis.Expect(a => a.Minimum).SetPropertyWithArgument(dateTime.ToOADate()); + var maximum = DateTime.Parse("2015/12/17"); + var minimum = DateTime.Parse("2015/12/3"); + chartAxis.Expect(a => a.Maximum).SetPropertyWithArgument(maximum.ToOADate()); + chartAxis.Expect(a => a.Minimum).SetPropertyWithArgument(minimum.ToOADate()); mocks.ReplayAll(); - var properties = new ChartAxisDateTimeProperties(chartAxis); - // Call - properties.Minimum = dateTime; + new ChartAxisDateTimeProperties(chartAxis) + { + Maximum = maximum, + Minimum = minimum + }; // Assert mocks.VerifyAll(); Index: Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisDoublePropertiesTest.cs =================================================================== diff -u -r62bda0a2744de5708f3cea188d90839e06908cc0 -r261638422bd5d4f04f8f4cc9862d2c0a8e83c500 --- Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisDoublePropertiesTest.cs (.../ChartAxisDoublePropertiesTest.cs) (revision 62bda0a2744de5708f3cea188d90839e06908cc0) +++ Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisDoublePropertiesTest.cs (.../ChartAxisDoublePropertiesTest.cs) (revision 261638422bd5d4f04f8f4cc9862d2c0a8e83c500) @@ -1,10 +1,78 @@ -using NUnit.Framework; +using System; +using Core.Common.Controls.Charting; +using Core.Plugins.CommonTools.Gui.Property.Charting; +using NUnit.Framework; +using Rhino.Mocks; namespace Core.Plugins.CommonTools.Gui.Test.Property.Charting { [TestFixture] public class ChartAxisDoublePropertiesTest { - + [Test] + public void Constructor_WithAxis_ExpectedValues() + { + // Call + var mocks = new MockRepository(); + var chartAxis = mocks.StrictMock(); + var properties = new ChartAxisDoubleProperties(chartAxis); + + // Assert + Assert.IsInstanceOf(properties); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var random = new Random(21); + var maximum = random.NextDouble(); + var minimum = random.NextDouble(); + var logaritmic = true; + var chartAxis = mocks.StrictMock(); + chartAxis.Expect(a => a.Maximum).Return(maximum); + chartAxis.Expect(a => a.Minimum).Return(minimum); + chartAxis.Expect(a => a.Logaritmic).Return(logaritmic); + + mocks.ReplayAll(); + + var properties = new ChartAxisDoubleProperties(chartAxis); + + // Call & Assert + Assert.AreEqual(maximum, properties.Maximum); + Assert.AreEqual(minimum, properties.Minimum); + Assert.AreEqual(logaritmic, properties.Logaritmic); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var chartAxis = mocks.StrictMock(); + var random = new Random(21); + var maximum = random.NextDouble(); + var minimum = random.NextDouble(); + var logaritmic = true; + chartAxis.Expect(a => a.Maximum).SetPropertyWithArgument(maximum); + chartAxis.Expect(a => a.Minimum).SetPropertyWithArgument(minimum); + chartAxis.Expect(a => a.Logaritmic).SetPropertyWithArgument(logaritmic); + + mocks.ReplayAll(); + + // Call + new ChartAxisDoubleProperties(chartAxis) + { + Maximum = maximum, + Minimum = minimum, + Logaritmic = logaritmic + }; + + // Assert + mocks.VerifyAll(); + } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisPropertiesTest.cs =================================================================== diff -u -r62bda0a2744de5708f3cea188d90839e06908cc0 -r261638422bd5d4f04f8f4cc9862d2c0a8e83c500 --- Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisPropertiesTest.cs (.../ChartAxisPropertiesTest.cs) (revision 62bda0a2744de5708f3cea188d90839e06908cc0) +++ Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartAxisPropertiesTest.cs (.../ChartAxisPropertiesTest.cs) (revision 261638422bd5d4f04f8f4cc9862d2c0a8e83c500) @@ -1,10 +1,89 @@ -using NUnit.Framework; +using System; +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Plugins.CommonTools.Gui.Property.Charting; +using NUnit.Framework; +using Rhino.Mocks; namespace Core.Plugins.CommonTools.Gui.Test.Property.Charting { [TestFixture] public class ChartAxisPropertiesTest { - + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var visible = true; + var automatic = true; + var title = "some title"; + var labels = true; + var labelsFont = new Font(FontFamily.GenericSansSerif, 12); + var titleFont = new Font(FontFamily.GenericSansSerif, 12); + + var chartAxis = mocks.StrictMock(); + chartAxis.Expect(a => a.Visible).Return(visible); + chartAxis.Expect(a => a.Automatic).Return(automatic); + chartAxis.Expect(a => a.Title).Return(title); + chartAxis.Expect(a => a.Labels).Return(labels); + chartAxis.Expect(a => a.LabelsFont).Return(labelsFont); + chartAxis.Expect(a => a.TitleFont).Return(titleFont); + + mocks.ReplayAll(); + + var properties = new TestChartAxisProperties(chartAxis); + + // Call & Assert + Assert.AreEqual(visible, properties.Visible); + Assert.AreEqual(automatic, properties.Automatic); + Assert.AreEqual(title, properties.Title); + Assert.AreEqual(labels, properties.Labels); + Assert.AreEqual(labelsFont, properties.LabelsFont); + Assert.AreEqual(titleFont, properties.TitleFont); + + mocks.VerifyAll(); + } + + [Test] + public void SetProperties_WithData_CallsSetters() + { + // Setup + var mocks = new MockRepository(); + var visible = true; + var automatic = true; + var title = "some title"; + var labels = true; + var labelsFont = new Font(FontFamily.GenericSansSerif, 12); + var titleFont = new Font(FontFamily.GenericSansSerif, 12); + + var chartAxis = mocks.StrictMock(); + chartAxis.Expect(a => a.Visible).SetPropertyWithArgument(visible); + chartAxis.Expect(a => a.Automatic).SetPropertyWithArgument(automatic); + chartAxis.Expect(a => a.Title).SetPropertyWithArgument(title); + chartAxis.Expect(a => a.Labels).SetPropertyWithArgument(labels); + chartAxis.Expect(a => a.LabelsFont).SetPropertyWithArgument(labelsFont); + chartAxis.Expect(a => a.TitleFont).SetPropertyWithArgument(titleFont); + mocks.ReplayAll(); + + // Call + new TestChartAxisProperties(chartAxis) + { + Visible = visible, + Automatic = automatic, + Title = title, + Labels = labels, + LabelsFont = labelsFont, + TitleFont = titleFont + }; + + // Assert + mocks.VerifyAll(); + } } + + public class TestChartAxisProperties : ChartAxisProperties + { + public TestChartAxisProperties(IChartAxis chartAxis) : base(chartAxis) {} + } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartFontPropertiesConverterTest.cs =================================================================== diff -u -r62bda0a2744de5708f3cea188d90839e06908cc0 -r261638422bd5d4f04f8f4cc9862d2c0a8e83c500 --- Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartFontPropertiesConverterTest.cs (.../ChartFontPropertiesConverterTest.cs) (revision 62bda0a2744de5708f3cea188d90839e06908cc0) +++ Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartFontPropertiesConverterTest.cs (.../ChartFontPropertiesConverterTest.cs) (revision 261638422bd5d4f04f8f4cc9862d2c0a8e83c500) @@ -1,10 +1,49 @@ -using NUnit.Framework; +using System.Drawing; +using Core.Plugins.CommonTools.Gui.Property.Charting; +using NUnit.Framework; namespace Core.Plugins.CommonTools.Gui.Test.Property.Charting { [TestFixture] public class ChartFontPropertiesConverterTest { - + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var converter = new ChartFontPropertiesConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void GetProperties_Always_ReturnsAllowedProperties() + { + // Setup + var converter = new ChartFontPropertiesConverter(); + // Call + var properties = converter.GetProperties(new Font(FontFamily.GenericSansSerif, 12)); + + // Assert + Assert.AreEqual(5, properties.Count); + var sizeProperty = properties.Find("Size", false); + var boldProperty = properties.Find("Bold", false); + var italicProperty = properties.Find("Italic", false); + var underlineProperty = properties.Find("Underline", false); + var strikeoutProperty = properties.Find("Strikeout", false); + + Assert.True(sizeProperty.IsReadOnly); + Assert.True(boldProperty.IsReadOnly); + Assert.True(italicProperty.IsReadOnly); + Assert.True(underlineProperty.IsReadOnly); + Assert.True(strikeoutProperty.IsReadOnly); + + Assert.AreEqual("Size", sizeProperty.DisplayName); + Assert.AreEqual("Bold", boldProperty.DisplayName); + Assert.AreEqual("Italic", italicProperty.DisplayName); + Assert.AreEqual("Underline", underlineProperty.DisplayName); + Assert.AreEqual("Strikeout", strikeoutProperty.DisplayName); + } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartPropertiesTest.cs =================================================================== diff -u -r62bda0a2744de5708f3cea188d90839e06908cc0 -r261638422bd5d4f04f8f4cc9862d2c0a8e83c500 --- Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartPropertiesTest.cs (.../ChartPropertiesTest.cs) (revision 62bda0a2744de5708f3cea188d90839e06908cc0) +++ Core/Plugins/test/Core.Plugins.CommonTools.Gui.Test/Property/Charting/ChartPropertiesTest.cs (.../ChartPropertiesTest.cs) (revision 261638422bd5d4f04f8f4cc9862d2c0a8e83c500) @@ -1,10 +1,81 @@ -using NUnit.Framework; +using System; +using System.Drawing; +using Core.Common.Controls.Charting; +using Core.Common.Gui; +using Core.Plugins.CommonTools.Gui.Property.Charting; +using NUnit.Framework; +using Rhino.Mocks; namespace Core.Plugins.CommonTools.Gui.Test.Property.Charting { [TestFixture] public class ChartPropertiesTest { + [Test] + public void Constructor_WithAxis_ExpectedValues() + { + // Call + var mocks = new MockRepository(); + var properties = new ChartProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var chartAxis = mocks.StrictMock(); + var chart = mocks.StrictMock(); + var legend = mocks.StrictMock(); + + var backgroundColor = Color.AliceBlue; + var showLegend = false; + var legendAlignment = LegendAlignment.Top; + var legendFont = new Font(FontFamily.GenericSansSerif, 12); + var title = "some title"; + var titleFont = new Font(FontFamily.GenericSansSerif, 12); + var titleVisible = false; + + chart.Expect(a => a.BackGroundColor).Return(backgroundColor); + chart.Expect(a => a.Title).Return(title); + chart.Expect(a => a.Font).Return(titleFont); + chart.Expect(a => a.TitleVisible).Return(titleVisible); + chart.Expect(a => a.LeftAxis).Return(chartAxis).Repeat.Twice(); + chart.Expect(a => a.BottomAxis).Return(chartAxis).Repeat.Twice(); + chart.Expect(a => a.RightAxis).Return(chartAxis).Repeat.Twice(); + + chart.Expect(a => a.Legend).Return(legend).Repeat.Times(3); + legend.Expect(a => a.Visible).Return(showLegend); + legend.Expect(a => a.Alignment).Return(legendAlignment); + legend.Expect(a => a.Font).Return(legendFont); + + chartAxis.Expect(a => a.IsDateTime).Return(false).Repeat.Times(3); + + mocks.ReplayAll(); + + var properties = new ChartProperties + { + Data = chart + }; + + // Call & Assert + Assert.AreEqual(backgroundColor, properties.BackgroundColor); + Assert.AreEqual(showLegend, properties.ShowLegend); + Assert.AreEqual(legendAlignment, properties.LegendAlignment); + Assert.AreEqual(legendFont, properties.LegendFont); + Assert.AreEqual(title, properties.Title); + Assert.AreEqual(titleFont, properties.TitleFont); + Assert.AreEqual(titleVisible, properties.TitleVisibile); + Assert.IsInstanceOf(properties.LeftAxis); + Assert.IsInstanceOf(properties.BottomAxis); + Assert.IsInstanceOf(properties.RightAxis); + + mocks.VerifyAll(); + } } } \ No newline at end of file