コード例 #1
0
        public void VideoItem_VerifyNumberOfProperties()
        {
            var obj = new VideoItem();

            var result = obj.GetType()
                         .GetProperties()
                         .Count();

            Assert.AreEqual(6, result);
        }
コード例 #2
0
        public void VideoItem_ShouldImplement_IDbModelInterface()
        {
            var obj = new VideoItem();

            var result = obj.GetType()
                         .GetInterfaces()
                         .Where(x => x == typeof(IDbModel))
                         .Any();

            Assert.IsTrue(result);
        }
コード例 #3
0
        public void VideoItem_VerifyNumberOfConstructors()
        {
            var obj = new VideoItem();

            var methodsCount = obj.GetType()
                               .GetMethods()
                               .Count();

            var propertiesCount = obj.GetType()
                                  .GetProperties()
                                  .Count();

            var result = obj.GetType()
                         .GetMembers()
                         .Count();

            result = result - propertiesCount - methodsCount;

            Assert.AreEqual(1, result);
        }
コード例 #4
0
        public void Id_ShouldHave_KeyAttribute()
        {
            var obj = new VideoItem();

            var result = obj.GetType()
                         .GetProperty("Id")
                         .GetCustomAttributes(false)
                         .Where(x => x.GetType() == typeof(KeyAttribute))
                         .Any();

            Assert.IsTrue(result);
        }
コード例 #5
0
        public void VideoItem_VerifyNumberOfMethods()
        {
            var methodsFromFramework = 4;
            var expectedMethodsCount = 0;
            var totalMethodsCount    = methodsFromFramework + expectedMethodsCount;

            var obj = new VideoItem();

            var numberOfMethodsComeFromProperties = obj.GetType()
                                                    .GetProperties()
                                                    .Select(x => 2)
                                                    .Sum();

            var result = obj.GetType()
                         .GetMethods()
                         .Count();

            result = result - numberOfMethodsComeFromProperties;

            Assert.AreEqual(totalMethodsCount, result);
        }
コード例 #6
0
        public void YouTubeUrl_ShouldHave_MaxLengthAttribute()
        {
            var obj = new VideoItem();

            var result = obj.GetType()
                         .GetProperty("YouTubeUrl")
                         .GetCustomAttributes(false)
                         .Where(x => x.GetType() == typeof(MaxLengthAttribute))
                         .Any();

            Assert.IsTrue(result);
        }
コード例 #7
0
        public void YouTubeUrl_ShouldHave_RightMaxValueFor_RequiredAttribute()
        {
            var obj = new VideoItem();

            var result = obj.GetType()
                         .GetProperty("YouTubeUrl")
                         .GetCustomAttributes(false)
                         .Where(x => x.GetType() == typeof(MaxLengthAttribute))
                         .Select(x => (MaxLengthAttribute)x)
                         .SingleOrDefault();

            Assert.IsNotNull(result);
            Assert.AreEqual(ValidationConstants.UrlLengthMaxValue, result.Length);
        }