Beispiel #1
0
        public void DefaultMessageErrorShouldExists()
        {
            var computer = new Computer {IpAddress = "aaa.bbb.ccc"};
            IClassValidator classValidator = GetClassValidator(typeof(Computer));

            var invalidValue = classValidator.GetInvalidValues(computer).First();

            invalidValue.Message.Should().Not.Be.EqualTo("{validator.ipaddress}");
        }
Beispiel #2
0
        public void TestValidIPAddresses()
        {
            var computer = new Computer { IpAddress = "192.168.0.1" };
            IClassValidator classValidator = GetClassValidator(typeof (Computer));
            classValidator.GetInvalidValues(computer).Should().Be.Empty();

            computer.IpAddress = "255.255.255.255";
            classValidator.GetInvalidValues(computer).Should().Be.Empty();

            computer.IpAddress = "192.168.0.0";
            classValidator.GetInvalidValues(computer).Should().Be.Empty();
        }
Beispiel #3
0
        public void TestInvalidIPAddresses()
        {
            var computer = new Computer();
            IClassValidator classValidator = GetClassValidator(typeof (Computer));

            computer.IpAddress = "aaa.bbb.ccc";
            classValidator.GetInvalidValues(computer).Should("aaa.bbb.ccc is not a valid IP").Not.Be.Empty();

            computer.IpAddress = "260.255.255.255";
            classValidator.GetInvalidValues(computer).Should("260.255.255.255 is not a valid IP").Not.Be.Empty();

            computer.IpAddress = "192.999.0.0";
            classValidator.GetInvalidValues(computer).Should("192.999.0.0 is not a valid IP").Not.Be.Empty();
        }
        public void TestValidIPAddresses()
        {
            Computer computer = new Computer();
            computer.IpAddress = "192.168.0.1";
            IClassValidator classValidator = GetClassValidator(typeof(Computer));
            InvalidValue[] ivs = classValidator.GetInvalidValues(computer);
            Assert.AreEqual(0, ivs.Length);

            computer.IpAddress = "255.255.255.255";
            ivs = classValidator.GetInvalidValues(computer);
            Assert.AreEqual(0, ivs.Length);

            computer.IpAddress = "192.168.0.0";
            ivs = classValidator.GetInvalidValues(computer);
            Assert.AreEqual(0, ivs.Length, "192.168.0.0 is a valid ip");
        }
        public void TestInvalidIPAddresses()
        {
            Computer computer = new Computer();
            computer.IpAddress = "aaa.bbb.ccc";
            IClassValidator classValidator = GetClassValidator(typeof(Computer));
            InvalidValue[] ivs = classValidator.GetInvalidValues(computer);
            Assert.AreEqual(1, ivs.Length, "aaa.bbb.ccc is not a valid IP");

            computer.IpAddress = "260.255.255.255";
            ivs = classValidator.GetInvalidValues(computer);
            Assert.AreEqual(1, ivs.Length, "260.255.255.255 is not a valid ip");

            computer.IpAddress = "192.999.0.0";
            ivs = classValidator.GetInvalidValues(computer);
            Assert.AreEqual(1, ivs.Length, "192.999.0.0 is not a valid ip");
        }