예제 #1
0
        public void Size2dCloneWorks()
        {
            var v = new Size2d(1, 2);
            var v2 = v.Clone();

            v2.Width = 3;

            Assert.NotEqual(v, v2);
            Assert.True(v.Equivalent(new Size2d(1, 2)));
        }
예제 #2
0
        public void Size2dApplyWorks()
        {
            var v = new Size2d(1.11, 2.22);

            v.Apply(Math.Round);

            Assert.True(v.Equivalent(new Size2d(1, 2)));

            v.Apply(val => { return val + 1; });

            Assert.True(v.Equivalent(new Size2d(2, 3)));
        }
예제 #3
0
        public void Size2dAddsCorrectly()
        {
            var v = new Size2d(2, 3);

            Assert.False(v == v + 0);
            Assert.False(v == v.Add(0));
            Assert.True(v.Equivalent(v + 0));
            Assert.True(v.Equivalent(v.Add(0)));
            Assert.True((v + v).Equivalent(new Size2d(4, 6)));
            Assert.True(v.Add(v).Equivalent(new Size2d(4, 6)));
            Assert.True((v + .1).Equivalent(new Size2d(2.1, 3.1)));
            Assert.True(v.Add(.1).Equivalent(new Size2d(2.1, 3.1)));
        }
예제 #4
0
        public void Size2dTriggerWorks()
        {
            var v = new Size2d(2, 3);
            double total = 0;
            Action<double> sum = (val) =>
            {
                total += val;
            };

            v.Trigger(sum);

            Assert.Equal(5, total);
        }
예제 #5
0
        public void Size2dSubtractsCorrectly()
        {
            var v = new Size2d(2, 3);

            Assert.False(v == v - 0);
            Assert.False(v == v.Subtract(0));
            Assert.False(-v == v.SubtractFrom(0));
            Assert.True(v.Equivalent(v - 0));
            Assert.True(v.Equivalent(v.Subtract(0)));
            Assert.True((-v).Equivalent(0 - v));
            Assert.True((-v).Equivalent(v.SubtractFrom(0)));
            Assert.True((v - v).Equivalent(Size2d.Zero));
            Assert.True((v.Subtract(v)).Equivalent(Size2d.Zero));
            Assert.True((v - .1).Equivalent(new Size2d(1.9, 2.9)));
            Assert.True((v.Subtract(.1)).Equivalent(new Size2d(1.9, 2.9)));
            Assert.True((.1 - v).Equivalent(new Size2d(-1.9, -2.9)));
            Assert.True((v.SubtractFrom(.1)).Equivalent(new Size2d(-1.9, -2.9)));
        }
예제 #6
0
 public BoundingRectangle(Size2d size)
 {
     Size = size;
 }
예제 #7
0
 public BoundingRectangle(double width, double height)
 {
     Size = new Size2d(width, height);
 }
예제 #8
0
 public bool Equivalent(Size2d s1)
 {
     return Width == s1.Width && Height == s1.Height;
 }
예제 #9
0
 public Size2d DivideFrom(Size2d s1)
 {
     return s1 / this;
 }
예제 #10
0
 public Size2d Divide(Size2d s1)
 {
     return this / s1;
 }
예제 #11
0
 public Size2d SubtractFrom(Size2d s1)
 {
     return s1 - this;
 }
예제 #12
0
 public Size2d Subtract(Size2d s1)
 {
     return this - s1;
 }
예제 #13
0
 public Size2d Multiply(Size2d s1)
 {
     return this * s1;
 }
예제 #14
0
 public Size2d Add(Size2d s1)
 {
     return this + s1;
 }
예제 #15
0
        public void Size2dMultipliesCorrectly()
        {
            var v = new Size2d(2, 3);

            Assert.False(Size2d.Zero == v * 0);
            Assert.False(Size2d.Zero == v.Multiply(0));
            Assert.True(Size2d.Zero.Equivalent(v * 0));
            Assert.True(Size2d.Zero.Equivalent(v.Multiply(0)));
            Assert.True((v * v).Equivalent(new Size2d(4, 9)));
            Assert.True(v.Multiply(v).Equivalent(new Size2d(4, 9)));
            Assert.True((v * .5).Equivalent(new Size2d(1, 1.5)));
            Assert.True(v.Multiply(.5).Equivalent(new Size2d(1, 1.5)));
        }
예제 #16
0
        public void Size2dDividesCorrectly()
        {
            var v = new Size2d(2, 4);

            Assert.False(v == v / 1);
            Assert.False(v == v.Divide(1));
            Assert.True(v.Equivalent(v / 1));
            Assert.True(v.Equivalent(v.Divide(1)));
            Assert.True(new Size2d(.5, .25).Equivalent(1 / v));
            Assert.True(new Size2d(.5, .25).Equivalent(v.DivideFrom(1)));
            Assert.True(new Size2d(20, 40).Equivalent(v / .1));
            Assert.True(new Size2d(20, 40).Equivalent(v.Divide(.1)));
        }