<commit_before>﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MlIB.Reply.Tests.Unit.Features
{
    [TestClass]
    public class Reply_Error_exception
    {

        //public static IReplyEx<TReturn> Error<TReturn>(Exception ex, string errorMessage = null, TReturn value = default(TReturn))

        //I:null
        //O:has error
        //O:default value
        //O:null error details
        [TestMethod]
        public void Reply_Error_exception_null()
        {
            Exception nullEx = null;
            var result = M.Reply.Error<int>(nullEx);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(null, result.Exception);  //O:null error details

            Assert.IsFalse(result.HasErrorMessage, "WHY HAVE MSG??");  //O:null error details
            Assert.AreEqual(null, result.ErrorMessage, "WHY NOT NULL MSG??");  //O:null error details
        }

        //I:valid
        //O:has error
        //O:default value
        //O:error details exception
        //O:exception msg for msg
        [TestMethod]
        public void Reply_Error_exception_valid()
        {
            var result = M.Reply.Error<int>(Stubs.Common.EXCEPTION);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);  //O:error details exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");     //O:exception msg for msg
            Assert.AreEqual(Stubs.Common.EXCEPTION.Message, result.ErrorMessage, "WHY NOT EXPECTED MSG??");     //O:exception msg for msg
        }

        //I:null, valid
        //O:has error
        //O:default value
        //O:error details exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_null_message_valid()
        {
            var result = M.Reply.Error<int>(Stubs.Common.EXCEPTION, Stubs.Common.MSG_ErrorFound);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);  //O:error details exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");     //O:exception msg for msg
            Assert.AreEqual(Stubs.Common.MSG_ErrorFound, result.ErrorMessage, "WHY NOT EXPECTED MSG??");     //O:exception msg for msg
        }

        //I:valid, valid
        //O:

        //I:null, empty
        //O:

        //I:valid, empty
        //O:

        //I:null, valid, valid
        //O:

        //I:valid, valid, valid
        //O:

        //I:null, empty, valid
        //O:

        //I:valid, empty, valid
        //O:

        //I:null, valid, valid exception
        //O:

        //I:valid, valid, valid exception
        //O:

        //I:null, empty, valid exception
        //O:

        //I:valid, empty, valid exception
        //O:

    }
}<commit_msg>TDD complete for Reply_Error_exception<commit_after>﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MlIB.Reply.Tests.Unit.Features
{
    [TestClass]
    public class Reply_Error_exception
    {

        //public static IReplyEx<TReturn> Error<TReturn>(Exception ex, string errorMessage = null, TReturn value = default(TReturn))

        //I:null exception
        //O:has error
        //O:default value
        //O:null error details
        [TestMethod]
        public void Reply_Error_exception_null()
        {
            Exception nullEx = null;
            var result = M.Reply.Error<int>(nullEx);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(null, result.Exception);  //O:null error details

            Assert.IsFalse(result.HasErrorMessage, "WHY HAVE MSG??");  //O:null error details
            Assert.AreEqual(null, result.ErrorMessage, "WHY NOT NULL MSG??");  //O:null error details
        }

        //I:valid exception
        //O:has error
        //O:default value
        //O:error details exception
        //O:exception msg for msg
        [TestMethod]
        public void Reply_Error_exception_valid()
        {
            var result = M.Reply.Error<int>(Stubs.Common.EXCEPTION);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);  //O:error details exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");     //O:exception msg for msg
            Assert.AreEqual(Stubs.Common.EXCEPTION.Message, result.ErrorMessage, "WHY NOT EXPECTED MSG??");     //O:exception msg for msg
        }

        //I:null exception, valid msg
        //O:has error
        //O:default value
        //O:null exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_null_message_valid()
        {
            Exception nullEx = null;
            var result = M.Reply.Error<int>(nullEx, Stubs.Common.MSG_ErrorFound);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(nullEx, result.Exception);   //O:null exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");     //O:expected error msg
            Assert.AreEqual(Stubs.Common.MSG_ErrorFound, result.ErrorMessage, "WHY NOT EXPECTED MSG??");    //O:expected error msg
        }

        //I:null exception, empty msg
        //O:has error
        //O:default value
        //O:error details exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_null_message_empty()
        {
            Exception nullEx = null;
            var result = M.Reply.Error<int>(nullEx, "");

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(nullEx, result.Exception);   //O:null exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");   //O:expected error msg
            Assert.AreEqual("", result.ErrorMessage, "WHY NOT EXPECTED MSG??");      //O:expected error msg
        }

        //I:valid exception, empty msg
        //O:has error
        //O:default value
        //O:error details exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_valid_message_empty()
        {
            var result = M.Reply.Error<int>(Stubs.Common.EXCEPTION, "");

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);  //O:error details exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");   //O:expected error msg
            Assert.AreEqual("", result.ErrorMessage, "WHY NOT EXPECTED MSG??");      //O:expected error msg
        }

        //I:valid exception, valid msg
        //O:has error
        //O:default value
        //O:error details exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_valid_message_valid()
        {
            var result = M.Reply.Error<int>(Stubs.Common.EXCEPTION, Stubs.Common.MSG_ErrorFound);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(default(int), result.Value, "WHY NO DEFAULT VALUE??");  //O:default value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);  //O:error details exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");   //O:expected error msg
            Assert.AreEqual(Stubs.Common.MSG_ErrorFound, result.ErrorMessage, "WHY NOT EXPECTED MSG??");      //O:expected error msg
        }

        //I:null exception, valid msg, valid value
        //O:has error
        //O:expected value
        //O:null exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_null_message_valid_value_valid()
        {
            Exception nullEx = null;
            var result = M.Reply.Error(nullEx, Stubs.Common.MSG_ErrorFound, Stubs.Common.VAL_anyValue);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(Stubs.Common.VAL_anyValue, result.Value, "WHY NO DEFAULT VALUE??");   //O:expected value
            Assert.AreEqual(nullEx, result.Exception);   //O:null exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");     //O:expected error msg
            Assert.AreEqual(Stubs.Common.MSG_ErrorFound, result.ErrorMessage, "WHY NOT EXPECTED MSG??");    //O:expected error msg
        }

        //I:valid exception, valid msg, valid value
        //O:has error
        //O:expected value
        //O:expected exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_valid_message_valid_value_valid()
        {
            var result = M.Reply.Error(Stubs.Common.EXCEPTION, Stubs.Common.MSG_ErrorFound, Stubs.Common.VAL_anyValue);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(Stubs.Common.VAL_anyValue, result.Value, "WHY NO DEFAULT VALUE??");   //O:expected value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);    //O:expected exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");     //O:expected error msg
            Assert.AreEqual(Stubs.Common.MSG_ErrorFound, result.ErrorMessage, "WHY NOT EXPECTED MSG??");    //O:expected error msg
        }

        //I:null exception, empty msg, valid value
        //O:has error
        //O:expected value
        //O:error details exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_null_message_empty_value_valid()
        {
            Exception nullEx = null;
            var result = M.Reply.Error(nullEx, "", Stubs.Common.VAL_anyValue);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(Stubs.Common.VAL_anyValue, result.Value, "WHY NO DEFAULT VALUE??");   //O:expected value
            Assert.AreEqual(nullEx, result.Exception);   //O:null exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");   //O:expected error msg
            Assert.AreEqual("", result.ErrorMessage, "WHY NOT EXPECTED MSG??");      //O:expected error msg
        }

        //I:valid exception, empty msg, valid value
        //O:has error
        //O:expected value
        //O:expected exception
        //O:empty error msg
        [TestMethod]
        public void Reply_Error_exception_valid_message_empty_value_valid()
        {
            var result = M.Reply.Error(Stubs.Common.EXCEPTION, "", Stubs.Common.VAL_anyValue);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(Stubs.Common.VAL_anyValue, result.Value, "WHY NO DEFAULT VALUE??");   //O:expected value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);    //O:expected exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");    //O:empty error msg
            Assert.AreEqual("", result.ErrorMessage, "WHY NOT EXPECTED MSG??");        //O:empty error msg
        }

        //I:valid exception, empty msg, valid value exception
        //O:has error
        //O:expected value
        //O:expected exception
        //O:empty error msg
        //O:exception not same as value
        [TestMethod]
        public void Reply_Error_exception_valid_message_empty_value_valid_whenException()
        {
            Exception ex = new Exception("blebleble");
            var result = M.Reply.Error(Stubs.Common.EXCEPTION, "", ex);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(ex, result.Value, "WHY NO DEFAULT VALUE??");   //O:expected value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);    //O:expected exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");    //O:empty error msg
            Assert.AreEqual("", result.ErrorMessage, "WHY NOT EXPECTED MSG??");       //O:empty error msg

            Assert.AreNotEqual(result.Exception, result.Value); //O:exception not same as value
        }
        
        //I:null exception, empty msg, valid value exception
        //O:has error
        //O:expected value
        //O:null exception
        //O:empty error msg
        [TestMethod]
        public void Reply_Error_exception_null_message_empty_value_valid_whenException()
        {
            Exception nullEx = null;
            Exception ex = new Exception("blebleble");
            var result = M.Reply.Error(nullEx, "", ex);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(ex, result.Value, "WHY NO DEFAULT VALUE??");   //O:expected value
            Assert.AreEqual(nullEx, result.Exception);    //O:null exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");   //O:empty error msg
            Assert.AreEqual("", result.ErrorMessage, "WHY NOT EXPECTED MSG??");       //O:empty error msg

            Assert.AreNotEqual(result.Exception, result.Value); //O:exception not same as value
        }

        //I:null exception, valid msg, valid value exception
        //O:has error
        //O:expected value
        //O:null exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_null_message_valid_value_valid_whenException()
        {
            Exception nullEx = null;
            Exception ex = new Exception("blebleble");
            var result = M.Reply.Error(nullEx, Stubs.Common.MSG_ErrorFound, ex);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(ex, result.Value, "WHY NO DEFAULT VALUE??");   //O:expected value
            Assert.AreEqual(nullEx, result.Exception);    //O:null exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");   //O:expected error msg
            Assert.AreEqual(Stubs.Common.MSG_ErrorFound, result.ErrorMessage, "WHY NOT EXPECTED MSG??");      //O:expected error msg

            Assert.AreNotEqual(result.Exception, result.Value); //O:exception not same as value
        }

        //I:valid exception, valid msg, valid value exception
        //O:has error
        //O:expected value
        //O:expected exception
        //O:expected error msg
        [TestMethod]
        public void Reply_Error_exception_valid_message_valid_value_valid_whenException()
        {
            Exception ex = new Exception("blebleble");
            var result = M.Reply.Error(Stubs.Common.EXCEPTION, Stubs.Common.MSG_ErrorFound, ex);

            Assert.IsTrue(result.HasError, "WHY NO ERROR??");  //O:has error
            Assert.AreEqual(ex, result.Value, "WHY NO DEFAULT VALUE??");   //O:expected value
            Assert.AreEqual(Stubs.Common.EXCEPTION, result.Exception);    //O:expected exception

            Assert.IsTrue(result.HasErrorMessage, "WHY NO MSG??");   //O:expected error msg
            Assert.AreEqual(Stubs.Common.MSG_ErrorFound, result.ErrorMessage, "WHY NOT EXPECTED MSG??");      //O:expected error msg

            Assert.AreNotEqual(result.Exception, result.Value); //O:exception not same as value
        }

    }
}
{'fraction_non_alphanumeric': 0.1200271387158453, 'fraction_numerical': 0.0, 'mean_word_length': 2.2164253124380084, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4152749', 'n_tokens_mistral': 4725, 'n_tokens_neox': 4679, 'n_words': 1122}