public void VideoItem_VerifyNumberOfProperties()
        {
            var obj = new VideoItem();

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

            Assert.AreEqual(6, result);
        }
        public void VideoItem_ShouldImplement_IDbModelInterface()
        {
            var obj = new VideoItem();

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

            Assert.IsTrue(result);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }