Exemple #1
0
        public void WorkerReview_VerifyNumberOfProperties()
        {
            var obj = new WorkerReview();

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

            Assert.AreEqual(8, result);
        }
        public void WorkerReviewClass_ShouldImplement_IDbModelInterface()
        {
            var obj = new WorkerReview();

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

            Assert.IsTrue(result);
        }
Exemple #3
0
        public void WorkerReview_VerifyNumberOfConstructors()
        {
            var obj = new WorkerReview();

            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);
        }
        public void Client_ShouldBe_Virtual()
        {
            var obj = new WorkerReview();

            var result = obj.GetType()
                         .GetProperty("Client")
                         .GetAccessors()
                         .Any(x => x.IsVirtual);

            Assert.IsTrue(result);
        }
Exemple #5
0
        public void ReviewContent_ShouldHave_MaxLengthAttribute()
        {
            var obj = new WorkerReview();

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

            Assert.IsTrue(result);
        }
        public void Score_ShouldHave_RangeAttribute()
        {
            var obj = new WorkerReview();

            var result = obj.GetType()
                         .GetProperty("Score")
                         .GetCustomAttributes(false)
                         .Where(x => x.GetType() == typeof(System.ComponentModel.DataAnnotations.RangeAttribute))
                         .Any();

            Assert.IsTrue(result);
        }
Exemple #7
0
        public void Id_ShouldHave_KeyAttribute()
        {
            var obj = new WorkerReview();

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

            Assert.IsTrue(result);
        }
Exemple #8
0
        public void WorkerReview_VerifyNumberOfMethods()
        {
            var methodsFromFramework = 4;
            var expectedMethodsCount = 0;
            var totalMethodsCount    = methodsFromFramework + expectedMethodsCount;

            var obj = new WorkerReview();

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

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

            result = result - numberOfMethodsComeFromProperties;

            Assert.AreEqual(totalMethodsCount, result);
        }
Exemple #9
0
        public void ReviewContent_ShouldHave_RightValueFor_MaxLengthAttribute()
        {
            var obj = new WorkerReview();

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

            Assert.IsNotNull(result);
            Assert.AreEqual(ValidationConstants.ReviewContentMaxLength, result.Length);
        }
        public void Score_shouldHave_RightMaxValueFor_RangeAttribute()
        {
            var obj = new WorkerReview();

            var result = obj.GetType()
                         .GetProperty("Score")
                         .GetCustomAttributes(false)
                         .Where(x => x.GetType() == typeof(System.ComponentModel.DataAnnotations.RangeAttribute))
                         .Select(x => (System.ComponentModel.DataAnnotations.RangeAttribute)x)
                         .SingleOrDefault();

            Assert.IsNotNull(result);
            Assert.AreEqual(ValidationConstants.ScoreMaxValue, result.Maximum);
        }