Esempio n. 1
0
        public void GetWallHoleData_Test()
        {
            var tl = new SizeF(10, 20);
            var tr = new SizeF(30, 40);
            var br = new SizeF(50, 60);
            var bl = new SizeF(70, 80);

            using (_mocks.Record())
            {
                SetupCommonResults(topLeft: tl, topRight: tr, bottomRight: br, bottomLeft: bl);
            }
            var target = new WallHole(_data, _topObject);

            target.MainOffset.Offset = 50;
            target.SideOffsets.Single(s => s.Side == 3).Offset = 100;
            target.SideOffsets.Single(s => s.Side == 7).Offset = 150;

            var wallHoleData = target.GetWallHoleData();

            VerifySize(_dimensions.Size, wallHoleData.MainDimension);
            VerifySize(tl, wallHoleData.Slants[0]);
            VerifySize(tr, wallHoleData.Slants[1]);
            VerifySize(br, wallHoleData.Slants[2]);
            VerifySize(bl, wallHoleData.Slants[3]);

            Assert.AreEqual(3, wallHoleData.Offsets.Count);
            Assert.AreEqual(50, wallHoleData.Offsets[-1]);
            Assert.AreEqual(100, wallHoleData.Offsets[3]);
            Assert.AreEqual(150, wallHoleData.Offsets[7]);
        }
Esempio n. 2
0
 private void VerifySides(WallHole target, params int[] sides)
 {
     foreach (var side in sides)
     {
         Assert.AreEqual(1, target.SideOffsets.Count(i => i.Side == side));
     }
 }
Esempio n. 3
0
        internal EditOffsetViewModel(XElement data, ITopObject topObject)
        {
            _data      = data;
            _topObject = topObject;
            _wallHole  = new WallHole(data, topObject);

            Init();

            this.SubmitCommand = new RelayCommand(Submit);
        }
Esempio n. 4
0
        private void VerifyPoints(WallHole target, params PointF[] points)
        {
            Assert.AreEqual(target.SideOffsets.Count, points.Length);
            for (int i = 0; i < points.Length; i++)
            {
                Assert.AreEqual(points[i], target.SideOffsets[i].Start);
            }

            for (int i = 0; i < target.SideOffsets.Count - 1; i++)
            {
                Assert.AreEqual(target.SideOffsets[i + 1].Start, target.SideOffsets[i].End);
            }
            Assert.AreEqual(target.SideOffsets.First().Start, target.SideOffsets.Last().End);
        }
Esempio n. 5
0
        public void GetWindowOutline_TopRight_DiffOffset_Remove2Parts_Test()
        {
            using (_mocks.Record())
            {
                SetupCommonResults(topRight: new SizeF(500, 900), bottomLeft: new SizeF(850, 400));
            }
            var target = new WallHole(_data, _topObject);

            target.MainOffset.Offset = 50;
            target.SideOffsets.Single(s => s.Side == 3).Offset = 100;
            target.SideOffsets.Single(s => s.Side == 7).Offset = 150;

            var result = target.GetWindowOutline();

            VerifyOutline(result, 798.728f, 783.622f, topRight: new SizeF(435.346f, 783.622f), bottomLeft: new SizeF(798.728f, 375.872f));
        }
Esempio n. 6
0
        public void GetWindowOutline_TopRight_DiffOffset_RemovePart_Test()
        {
            using (_mocks.Record())
            {
                SetupCommonResults(topRight: new SizeF(940, 1000));
            }
            var target = new WallHole(_data, _topObject);

            target.MainOffset.Offset = 50;
            target.SideOffsets.Single(s => s.Side == 3).Offset = 100;
            target.SideOffsets.Single(s => s.Side == 6).Offset = 20;

            var result = target.GetWindowOutline();

            VerifyOutline(result, 793.956f, 844.633f, topRight: new SizeF(793.956f, 844.633f));
        }
Esempio n. 7
0
        public void GetWindowOutline_TopLeftTriangle_SameOffset_Test()
        {
            using (_mocks.Record())
            {
                SetupCommonResults(topLeft: new SizeF(1000, 1000));
            }
            var target = new WallHole(_data, _topObject);

            target.MainOffset.Offset = 50;

            var result = target.GetWindowOutline();

            float a = 829.289f;

            VerifyOutline(result, a, a, topLeft: new SizeF(a, a));
        }
Esempio n. 8
0
        public void Ctor_TopLeftTriangle_Test()
        {
            using (_mocks.Record())
            {
                SetupCommonResults(topLeft: new SizeF(1000, 1000));
            }

            var target = new WallHole(_data, _topObject);

            Assert.AreEqual(3, target.SideOffsets.Count);
            VerifySides(target, 1, 4, 6);
            VerifyPoints(target,
                         new PointF(0, 1000),
                         new PointF(1000, 0),
                         new PointF(1000, 1000));
            VerifyTopDims(target, 1000);
            VerifyLeftDims(target, 1000);
            VerifyRightDims(target);
            VerifyBottomDims(target);
        }
Esempio n. 9
0
        public void Ctor_BottomLeft_Test()
        {
            using (_mocks.Record())
            {
                SetupCommonResults(bottomLeft: new SizeF(300, 400));
            }

            var target = new WallHole(_data, _topObject);

            Assert.AreEqual(5, target.SideOffsets.Count);
            VerifySides(target, 0, 2, 4, 6, 7);
            VerifyPoints(target,
                         new PointF(0, 600),
                         new PointF(0, 0),
                         new PointF(1000, 0),
                         new PointF(1000, 1000),
                         new PointF(300, 1000));
            VerifyTopDims(target, 1000);
            VerifyLeftDims(target, 1000, new float[] { 600, 400 });
            VerifyRightDims(target);
            VerifyBottomDims(target, new float[] { 300, 700 });
        }
Esempio n. 10
0
 private void VerifyBottomDims(WallHole target, float[] subDims = null)
 {
     VerifySubSideDims(target.BottomDims, subDims);
 }
Esempio n. 11
0
 private void VerifyRightDims(WallHole target, float[] subDims = null)
 {
     VerifySubSideDims(target.RightDims, subDims);
 }
Esempio n. 12
0
 private void VerifyLeftDims(WallHole target, float mainDim, float[] subDims = null)
 {
     VerifyMainSideDims(target.LeftDims, mainDim, subDims);
 }