public void Duplicate_ReticleElement()
        {
            BallisticCalculatorNet.ReticleEditor.AppForm form = new BallisticCalculatorNet.ReticleEditor.AppForm();
            form.LoadReticle(new MilDotReticle(), "mildot");
            var lb = form.ListBox("reticleItems");
            var originalListBoxItemsCount = lb.Items.Count;

            var elementToDuplicate    = form.Reticle.Elements[1];
            var originalElementsCount = form.Reticle.Elements.Count;

            form.Reticle.Elements.Should().Contain(elementToDuplicate);

            form.DuplicateItem(elementToDuplicate);

            lb.Should()
            .HaveItemsCount(originalListBoxItemsCount + 1)
            .And.HaveItemMatching <object>(i => ReferenceEquals(i, elementToDuplicate))
            .And.HaveItemMatching <object>(i => i.Equals(elementToDuplicate) && !ReferenceEquals(i, elementToDuplicate));

            form.Reticle.Elements.Should()
            .HaveCount(originalElementsCount + 1)
            .And.Contain(i => ReferenceEquals(i, elementToDuplicate))
            .And.Contain(i => i.Equals(elementToDuplicate) && !ReferenceEquals(i, elementToDuplicate));

            lb.Items[^ 1].Should().Match(i => i.Equals(elementToDuplicate) && !ReferenceEquals(i, elementToDuplicate));
        public void Delete_ReticleElement()
        {
            BallisticCalculatorNet.ReticleEditor.AppForm form = new BallisticCalculatorNet.ReticleEditor.AppForm();
            form.LoadReticle(new MilDotReticle(), "mildot");

            var originalListBoxItemsCount = form.ListBox("reticleItems").Items.Count;

            var elementToDelete       = form.Reticle.Elements[1];
            var originalElementsCount = form.Reticle.Elements.Count;

            form.Reticle.Elements.Should().Contain(elementToDelete);

            form.DeleteItem(elementToDelete);

            form.ListBox("reticleItems").Should()
            .HaveItemsCount(originalListBoxItemsCount - 1)
            .And
            .HaveNotItemsMatching <object>(i => ReferenceEquals(i, elementToDelete));

            form.Reticle.Elements.Should().HaveCount(originalElementsCount - 1);
            form.Reticle.Elements.Should().NotContain(elementToDelete);
        }
Esempio n. 3
0
        public void NewReticle()
        {
            BallisticCalculatorNet.ReticleEditor.AppForm appForm = new BallisticCalculatorNet.ReticleEditor.AppForm();

            //make sure reticle is loaded
            appForm.TextBox("reticleName").Should().HaveNoText();
            appForm.MeasurementControl("reticleWidth").Should().HaveExactValue(AngularUnit.Mil.New(10));
            appForm.MeasurementControl("reticleHeight").Should().HaveExactValue(AngularUnit.Mil.New(10));
            appForm.MeasurementControl("zeroOffsetX").Should().HaveExactValue(AngularUnit.Mil.New(5));
            appForm.MeasurementControl("zeroOffsetY").Should().HaveExactValue(AngularUnit.Mil.New(5));

            appForm.ListBox("reticleItems").Should().HaveNoItems();
        }
Esempio n. 4
0
        public void LoadReticle()
        {
            BallisticCalculatorNet.ReticleEditor.AppForm appForm = new BallisticCalculatorNet.ReticleEditor.AppForm();

            MilDotReticle r1 = new MilDotReticle();

            using (var ms1 = new MemoryStream())
            {
                r1.BallisticXmlSerialize(ms1);
                using var ms2 = new MemoryStream(ms1.ToArray());
                appForm.LoadReticle(ms2, "reticle1");
            }

            //make sure reticle is loaded
            appForm.ReticleFileName.Should().Be("reticle1");
            appForm.Reticle.Name.Should().Be(r1.Name);

            appForm.TextBox("reticleName").Should().HaveText(r1.Name);
            appForm.MeasurementControl("reticleWidth").Should().HaveExactValue(r1.Size.X);
            appForm.MeasurementControl("reticleHeight").Should().HaveExactValue(r1.Size.Y);
            appForm.MeasurementControl("zeroOffsetX").Should().HaveExactValue(r1.Zero.X);
            appForm.MeasurementControl("zeroOffsetY").Should().HaveExactValue(r1.Zero.Y);

            var lb = appForm.ListBox("reticleItems");

            lb.Should().Exist();
            lb.Should().HaveItemsCount(r1.Elements.Count + r1.BulletDropCompensator.Count);
            lb.Should().HaveIndexSelected(-1);

            //wrong reticle, take it from control!!!
            foreach (var element in appForm.Reticle.Elements)
            {
                lb.Should().HaveItemMatching <object>(lbi => ReferenceEquals(lbi, element));
            }

            foreach (var element in appForm.Reticle.BulletDropCompensator)
            {
                lb.Should().HaveItemMatching <object>(lbi => ReferenceEquals(lbi, element));
            }
        }