public void ZoomScale_ZoomOnCenterValue(AxisType axisType) { IFixture fixture = new Fixture().Customize(new ZedGraphCustomization()); double zoomFraction = this.random.NextDouble() * 2; var min = fixture.Create <double>(); double centerValue = min + fixture.Create <double>(); double max = centerValue + fixture.Create <double>(); Axis axis = fixture.Create <Axis>() .OfType(axisType) .WithScale(min, max); Scale scale = axis.Scale; double linearMax = scale.Linearize(max); double linearMin = scale.Linearize(min); double expectedMin = scale.DeLinearize(centerValue - ((centerValue - linearMin) * zoomFraction)); double expectedMax = scale.DeLinearize(centerValue + ((linearMax - centerValue) * zoomFraction)); var sut = new TestZedGraphControl(); sut.ZoomScale(axis, zoomFraction, centerValue, ZoomOnCenterValue); Assert.That( scale.Min, Is.EqualTo(expectedMin) .Within(0.001), "The scale's minimum was not the expected value"); Assert.That( scale.Max, Is.EqualTo(expectedMax) .Within(0.001), "The scale's maximum was not the expected value"); Assert.That(scale.MinAuto, Is.False, "The scale's automatic minimum flag was not set to false"); Assert.That(scale.MinAuto, Is.False, "The scale's automatic maximum flag was not set to false"); }
public void ZoomScale_AxisIsNull_DoesNotThrowException() { IFixture fixture = new Fixture().Customize(new ZedGraphCustomization()); var sut = new TestZedGraphControl(); Assert.That( () => sut.ZoomScale(null, fixture.Create <double>(), fixture.Create <double>(), fixture.Create <bool>()), Throws.Nothing); }
public void ZoomScale_ZoomFractionGreaterThanMaximum_ScaleDoesNotChange() { IFixture fixture = new Fixture().Customize(new ZedGraphCustomization()); var min = fixture.Create <double>(); var max = fixture.Create <double>(); Axis axis = fixture.Create <Axis>() .WithScale(min, max); Scale scale = axis.Scale; scale.MinAuto = scale.MaxAuto = true; var sut = new TestZedGraphControl(); sut.ZoomScale(axis, MaxZoomFraction, fixture.Create <double>(), fixture.Create <bool>()); Assert.That(scale.Min, Is.EqualTo(min), "The scale's minimum value has changed unexpectantly"); Assert.That(scale.Max, Is.EqualTo(max), "The scale's maximum value has changed unexpectantly"); Assert.That(scale.MinAuto, Is.True, "The scale's automatic minimum flag appears to have changed"); Assert.That(scale.MaxAuto, Is.True, "The scale's automatic maximum flag appears to have changed"); }