public void TestGetEvaluation() { var service = new EvaluationsService(new EvaluationsStubDao()); var actual = service.GetEvaluation(Guid.Parse("11111111-1111-1111-1111-111111111112")); Assert.NotNull(actual); }
public void TestGetEvaluations() { var service = new EvaluationsService(new EvaluationsStubDao()); var actual = service.GetEvaluations(); Assert.NotNull(actual); }
public void TestCreateEvaluation_Header_Text_Value_IsAlphaNumeric_Throws_Exception() { this.ValidationMockEvaluation.Headers.Add(new Data() { Value = "!@ThisIsATittle@!", IdTemplateDataField = Guid.Parse("00000001-0001-0000-0000-000000000000") }); var service = new EvaluationsService(new EvaluationsStubDao()); Assert.Throws <ValidationErrorServiceException>(() => service.CreateEvaluation(this.ValidationMockEvaluation)); }
public void TestCreateEvaluation_Header_Text_Value_MaxCharViolation_Throws_Exception() { this.ValidationMockEvaluation.Headers.Add(new Data() { Value = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", IdTemplateDataField = Guid.Parse("00000001-0001-0000-0000-000000000000") }); var service = new EvaluationsService(new EvaluationsStubDao()); Assert.Throws <ValidationErrorServiceException>(() => service.CreateEvaluation(this.ValidationMockEvaluation)); }
public void TestUpdateEvaluation_Succesful_Update() { var service = new EvaluationsService(new EvaluationsStubDao()); var evaluations = service.GetEvaluations(); var actual = evaluations[0]; var expected = new Evaluation { Id = actual.Id, Name = "Updated name" }; service.UpdateEvaluation(expected); Assert.Equal(expected.Name, actual.Name); }
public void TestDeleteNonExistingEvaluation_Throws_ItemNotFoundException_Message() { var expected = "Unable to find an evaluation with id f480b496-2356-402b-9fdc-a1893cc64e16"; try { var service = new EvaluationsService(new EvaluationsStubDao()); service.DeleteEvaluation(Guid.Parse("f480b496-2356-402b-9fdc-a1893cc64e16")); } catch (Exception e) { Assert.Equal(expected, e.Message); } }
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); } }
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); } }
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); } }
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); }
public void TestUpdateEvaluationWithEditDate_Throws_InternalErrorDaoException() { var mockEvaluation = new Evaluation() { Id = Guid.Parse("11111111-1111-1111-1111-111111111114"), Name = "New Evaluation", EditDate = DateTime.Now }; var expected = "Bad arguments, cannot update existing evaluation Edit Date"; try { var service = new EvaluationsService(new EvaluationsStubDao()); service.UpdateEvaluation(mockEvaluation); } catch (Exception e) { Assert.Equal(expected, e.Message); } }
public void TestDeleteNonExistingEvaluation_Throws_ItemNotFoundException() { var service = new EvaluationsService(new EvaluationsStubDao()); Assert.Throws <ItemNotFoundServiceException>(() => service.DeleteEvaluation(Guid.Parse("f480b496-2356-402b-9fdc-a1893cc64e16"))); }
public void TestDeleteEvaluation() { var service = new EvaluationsService(new EvaluationsStubDao()); service.DeleteEvaluation(Guid.Parse("11111111-1111-1111-1111-111111111113")); }