コード例 #1
0
        public void Required()
        {
            var model = new TableDescViewModel();

            var result = model.Validate();

            Assert.True(result.Any());

            Assert.Equal("Description", result.ElementAtOrDefault(0).MemberNames.FirstOrDefault());
            Assert.Equal("The Description field is required.", result.ElementAtOrDefault(0).ErrorMessage);
        }
コード例 #2
0
        public void Valid()
        {
            var model = new TableDescViewModel()
            {
                Description = "Test"
            };

            var result = model.Validate();

            Assert.False(result.Any());
        }
コード例 #3
0
        public void RangeOrLength()
        {
            var model = new TableDescViewModel()
            {
                Description = "Test",
                Id          = -1
            };

            var result = model.Validate();

            Assert.True(result.Any());

            Assert.Equal("Id", result.ElementAtOrDefault(0).MemberNames.FirstOrDefault());
            Assert.Equal("The field Id must be between 0 and 9,223372036854776E+18.", result.ElementAtOrDefault(0).ErrorMessage);
        }
コード例 #4
0
        public void FromEntity()
        {
            var entity = new TableEntity()
            {
                Description = "Test",
                Id          = 1
            };
            var model = new TableDescViewModel(entity);

            var result = model.Validate();

            Assert.False(result.Any());

            Assert.Equal(entity.Description, model.Description);
            Assert.Equal(entity.Id, model.Id);
        }