コード例 #1
0
        public void ValidateTest()
        {
            AssertHelper.ExpectedException<ArgumentNullException>(() => DataErrorInfoExtensions.Validate(null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => DataErrorInfoExtensions.Validate(null, "Name"));

            MockEntity entity = new MockEntity();
            entity.Error = "Test Error";
            Assert.AreEqual("Test Error", entity.Validate());
            entity.Error = null;
            Assert.AreEqual("", entity.Validate());

            entity.Errors.Add("Name", "Name Error");
            Assert.AreEqual("Name Error", entity.Validate("Name"));
            entity.Errors.Add("Address", null);
            Assert.AreEqual("", entity.Validate("Address"));
        }
コード例 #2
0
        public void ValidateTest()
        {
            AssertHelper.ExpectedException <ArgumentNullException>(() => DataErrorInfoExtensions.Validate(null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => DataErrorInfoExtensions.Validate(null, "Name"));

            var entity = new MockEntity();

            entity.Error = "Test Error";
            Assert.AreEqual("Test Error", entity.Validate());
            entity.Error = null;
            Assert.AreEqual("", entity.Validate());

            entity.Errors.Add("Name", "Name Error");
            Assert.AreEqual("Name Error", entity.Validate("Name"));
            entity.Errors.Add("Address", null);
            Assert.AreEqual("", entity.Validate("Address"));
        }