示例#1
0
        public void AbsoluteOrDefault_should_apply_proper_value()
        {
            var input = 10;

            SizeUnit.Unlimited.AbsoluteOrDefault(input).ShouldBe(10);
            SizeUnit.NotSet.AbsoluteOrDefault(input).ShouldBe(10);
            SizeUnit.Absolute(30).AbsoluteOrDefault(input).ShouldBe(30);
        }
示例#2
0
        public void Spacer_should_initialize_properly_with_1_parameter()
        {
            var distance = SizeUnit.Absolute(15);
            var spacer   = new Spacer(distance);

            spacer.Top.ShouldBe(distance);
            spacer.Bottom.ShouldBe(distance);
            spacer.Left.ShouldBe(distance);
            spacer.Right.ShouldBe(distance);
            spacer.ToString().ShouldBe("15 15 15 15");
        }
示例#3
0
        public void Parse_should_properly_interpret_values()
        {
            SizeUnit.Parse("*").ShouldBe(SizeUnit.Unlimited);
            SizeUnit.Parse("").ShouldBe(SizeUnit.NotSet);
            SizeUnit.Parse("-").ShouldBe(SizeUnit.NotSet);
            SizeUnit.Parse(null).ShouldBe(SizeUnit.NotSet);
            SizeUnit.Parse(" ").ShouldBe(SizeUnit.NotSet);
            SizeUnit.Parse("15").ShouldBe(SizeUnit.Absolute(15));

            Assert.Throws <ArgumentException>(() => SizeUnit.Parse("x")).Message.ShouldStartWith("Provided value is not a valid SizeUnit: x");
        }
示例#4
0
        public void Spacer_should_initialize_properly_with_2_parameters()
        {
            var vertical   = SizeUnit.Absolute(15);
            var horizontal = SizeUnit.Absolute(25);
            var spacer     = new Spacer(vertical, horizontal);

            spacer.Top.ShouldBe(vertical);
            spacer.Bottom.ShouldBe(vertical);
            spacer.Left.ShouldBe(horizontal);
            spacer.Right.ShouldBe(horizontal);
            spacer.ToString().ShouldBe("15 25 15 25");
        }
示例#5
0
        public void Spacer_should_initialize_properly_with_4_parameters()
        {
            var top    = SizeUnit.Absolute(15);
            var left   = SizeUnit.Absolute(25);
            var bottom = SizeUnit.Absolute(35);
            var right  = SizeUnit.Absolute(45);
            var spacer = new Spacer(top, left, bottom, right);

            spacer.Top.ShouldBe(top);
            spacer.Bottom.ShouldBe(bottom);
            spacer.Left.ShouldBe(left);
            spacer.Right.ShouldBe(right);
            spacer.ToString().ShouldBe("15 25 35 45");
        }
示例#6
0
        public void It_should_support_Absolute_value()
        {
            var x = SizeUnit.Absolute(10);

            x.Value.ShouldBe(10);
            x.IsAbsolute.ShouldBeTrue();
            x.IsUnlimited.ShouldBeFalse();
            x.IsNotSet.ShouldBeFalse();
            x.ToString().ShouldBe("10");

            SizeUnit y = 10;

            y.ShouldBe(x);
            SizeUnit.Zero.Value.ShouldBe(0);
        }
示例#7
0
        public void SizeUnit_should_have_equality_operators()
        {
            Assert.True(SizeUnit.Unlimited == SizeUnit.Unlimited);
            Assert.True(SizeUnit.NotSet == SizeUnit.NotSet);
            Assert.True(SizeUnit.Absolute(10) == SizeUnit.Absolute(10));

            Assert.False(SizeUnit.Unlimited == SizeUnit.NotSet);
            Assert.False(SizeUnit.NotSet == SizeUnit.Absolute(10));
            Assert.False(SizeUnit.Absolute(10) == SizeUnit.Unlimited);
            Assert.False(SizeUnit.Absolute(10) == SizeUnit.Absolute(11));

            Assert.False(SizeUnit.Unlimited != SizeUnit.Unlimited);
            Assert.False(SizeUnit.NotSet != SizeUnit.NotSet);
            Assert.False(SizeUnit.Absolute(10) != SizeUnit.Absolute(10));

            Assert.True(SizeUnit.Unlimited != SizeUnit.NotSet);
            Assert.True(SizeUnit.NotSet != SizeUnit.Absolute(10));
            Assert.True(SizeUnit.Absolute(10) != SizeUnit.Unlimited);
            Assert.True(SizeUnit.Absolute(10) != SizeUnit.Absolute(11));
        }