Esempio n. 1
0
        public void TestCreateEvaluation_Header_Text_Value_MinCharViolation_Throws_Exception()
        {
            this.ValidationMockEvaluation.Headers.Add(new Data()
            {
                Value = "123",
                IdTemplateDataField = Guid.Parse("00000001-0001-0000-0000-000000000000")
            });

            var service = new EvaluationsService(new EvaluationsStubDao());

            Assert.Throws <ValidationErrorServiceException>(() => service.CreateEvaluation(this.ValidationMockEvaluation));
        }
Esempio n. 2
0
        public void TestCreateEvaluation_Header_Text_Value_IsAlphaNumeric_Throws_Exception_Message()
        {
            var expected = "Validation fail, header item should only contain alphanumeric characters.";

            try
            {
                this.ValidationMockEvaluation.Headers.Add(new Data()
                {
                    Value = "!@ThisIsATittle@!",
                    IdTemplateDataField = Guid.Parse("00000001-0001-0000-0000-000000000000")
                });

                var service = new EvaluationsService(new EvaluationsStubDao());
                service.CreateEvaluation(this.ValidationMockEvaluation);
            }
            catch (Exception e)
            {
                Assert.Equal(expected, e.Message);
            }
        }
Esempio n. 3
0
        public void TestCreateEvaluation_Header_Text_Value_MaxCharViolation_Throws_Exception_Message()
        {
            var expected = "Validation fail, data text length should be smaller or equal to the MaxChar limit.";

            try
            {
                this.ValidationMockEvaluation.Headers.Add(new Data()
                {
                    Value = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901",
                    IdTemplateDataField = Guid.Parse("00000001-0001-0000-0000-000000000000")
                });

                var service = new EvaluationsService(new EvaluationsStubDao());
                service.CreateEvaluation(this.ValidationMockEvaluation);
            }
            catch (Exception e)
            {
                Assert.Equal(expected, e.Message);
            }
        }
Esempio n. 4
0
        public void TestCreateEvaluation_Header_Text_Value_EmptyString_Throws_Exception_Message()
        {
            var expected = "Header Text cannot have an empty string as a value.";

            try
            {
                this.ValidationMockEvaluation.Headers.Add(new Data()
                {
                    Value = string.Empty,
                    IdTemplateDataField = Guid.Parse("00000001-0001-0000-0000-000000000000")
                });

                var service = new EvaluationsService(new EvaluationsStubDao());
                service.CreateEvaluation(this.ValidationMockEvaluation);
            }
            catch (Exception e)
            {
                Assert.Equal(expected, e.Message);
            }
        }
Esempio n. 5
0
        public void TestPostEvaluation()
        {
            Memory.Templates.List.Add(new Template()
            {
                Id = Guid.Parse("00000001-0000-0000-0000-000000000000"),
                EvalNameMaxChars   = 150,
                AllowedCharsRule   = @"^[\w\s]+$",
                ValueRequired      = true,
                Name               = "Evaluation Header Test Template",
                ScoreFormula       = "sum(i, 0, questionsLength, questionResult(i))",
                QualificationRules = new Dictionary <string, object>()
                {
                    { "Min", 0 },
                    { "MinRanges", 1 }
                },
                Headers = new List <DataField>
                {
                    new TextField()
                    {
                        Id = Guid.Parse("00000001-0001-0000-0000-000000000000"),
                        AllowedCharsRule = @"^[\w\s]+$",
                        ValueRequired    = true,
                        Input            = false,
                        Label            = "Title",
                        Type             = DataFieldType.Text,
                        MinChar          = 4,
                        MaxChar          = 150
                    }
                }
            });
            var expected = new Evaluation()
            {
                Name       = "New Evaluation",
                IdTemplate = Guid.Parse("00000001-0000-0000-0000-000000000000")
            };

            var service = new EvaluationsService(new EvaluationsStubDao());
            var actual  = service.CreateEvaluation(expected);

            Assert.True(expected.Name == actual.Name);
        }