Beispiel #1
0
        public void TestHasErrors()
        {
            var errorMsgContainer = new GojulValidationErrorMessageContainer <string, string>();

            Assert.False(errorMsgContainer.HasErrors);

            errorMsgContainer.AddError(new GojulValidationErrorMessage <string, string>("hello", "world"));
            Assert.True(errorMsgContainer.HasErrors);
        }
Beispiel #2
0
        public void TestAddErrorOnAssertion()
        {
            var errorMsgContainer = new GojulValidationErrorMessageContainer <string, string>();

            errorMsgContainer.AddError(1 == 1, () => new GojulValidationErrorMessage <string, string>("foo", "bar"));
            errorMsgContainer.AddError(1 == 0, () => new GojulValidationErrorMessage <string, string>("hello", "world"));

            Assert.Equal(1, errorMsgContainer.Messages.Count);
            Assert.Equal(new GojulValidationErrorMessage <string, string>("hello", "world"), errorMsgContainer.Messages[0]);
        }
Beispiel #3
0
        public void TestAddError()
        {
            var errorMsgContainer = new GojulValidationErrorMessageContainer <string, string>();

            var msg = new GojulValidationErrorMessage <string, string>("hello", "world");

            errorMsgContainer.AddError(msg);

            Assert.Equal(1, errorMsgContainer.Messages.Count);
            Assert.Equal(msg, errorMsgContainer.Messages[0]);
        }
Beispiel #4
0
        public void TestAddErrorWithNullErrorThrowsException()
        {
            var errorMsgContainer = new GojulValidationErrorMessageContainer <string, string>();

            Assert.Throws <ArgumentNullException>(() => errorMsgContainer.AddError(null));
        }
Beispiel #5
0
        public void TestAddErrorOnAssertionWithFalseAssertionAndNullGeneratedMessageThrowsException()
        {
            var errorMsgContainer = new GojulValidationErrorMessageContainer <string, string>();

            Assert.Throws <ArgumentNullException>(() => errorMsgContainer.AddError(false, () => null));
        }
Beispiel #6
0
 public Task ValidateAsync(string element, GojulValidationErrorMessageContainer <string, string> errorMessageContainer)
 {
     errorMessageContainer.AddError(new GojulValidationErrorMessage <string, string>("foo", "bar"));
     return(Task.CompletedTask);
 }