예제 #1
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)));
        }
예제 #2
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)));
        }
예제 #3
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)));
        }
예제 #4
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)));
        }
예제 #5
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)));
        }