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

namespace MlIB.Reply.Tests.Unit.Features
{
    [TestClass]
    public class static_Reply_From__action
    {
        // UNIT UNDER TEST:
        // public static IReplyEx<Exception> From(Action action)


        //I: action null
        //O: NullReferenceException
        //O: "ERROR: CANNOT EXECUTE A NULL ACTION!!"
        [TestMethod]
        public void static_Reply_From_action_null()
        {
            try
            {
                M.Action action = null;
                var result = M.Reply.From(action);
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(NullReferenceException), "FAIL TYPE");
                Assert.AreEqual("ERROR: CANNOT EXECUTE A NULL ACTION!!", ex.Message, "FAIL Message");
            }
        }

        //I: action ok
        //O: HasError false
        //O: Value null
        //O: Exception null
        [TestMethod]
        public void static_Reply_From_action_ok()
        {
            var result = M.Reply.From(() => Stubs.VoidMethods.PlayStaticSound());

            Assert.IsFalse(result.HasError, "FAIL HasError");
            Assert.IsNull(result.Value, "FAIL Value");
            Assert.IsNull(result.Exception, "FAIL Exception");
        }

        //I: action throwing
        //O: HasError true
        //O: Value exception
        //O: Exception exception
        [TestMethod]
        public void static_Reply_From_action_throwing()
        {
            var result = M.Reply.From(() => Stubs.VoidMethods.PlayInexistentSound());

            Assert.IsTrue(result.HasError, "FAIL HasError");
            Assert.AreSame(Stubs.VoidMethods.EXCEPTION, result.Value, "FAIL Value");
            Assert.AreSame(Stubs.VoidMethods.EXCEPTION, result.Exception, "FAIL Exception");
        }

    }
}
<commit_msg>Add check for HasException on test static_Reply_From__action<commit_after>﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MlIB.Reply.Tests.Unit.Features
{
    [TestClass]
    public class static_Reply_From__action
    {
        // UNIT UNDER TEST:
        // public static IReplyEx<Exception> From(Action action)


        //I: action null
        //O: NullReferenceException
        //O: "ERROR: CANNOT EXECUTE A NULL ACTION!!"
        [TestMethod]
        public void static_Reply_From_action_null()
        {
            try
            {
                M.Action action = null;
                var result = M.Reply.From(action);
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(NullReferenceException), "FAIL TYPE");
                Assert.AreEqual("ERROR: CANNOT EXECUTE A NULL ACTION!!", ex.Message, "FAIL Message");
            }
        }

        //I: action ok
        //O: HasError false
        //O: HasException false
        //O: Value null
        //O: Exception null
        [TestMethod]
        public void static_Reply_From_action_ok()
        {
            var result = M.Reply.From(() => Stubs.VoidMethods.PlayStaticSound());

            Assert.IsFalse(result.HasError, "FAIL HasError");
            Assert.IsFalse(result.HasException, "FAIL HasException");
            Assert.IsNull(result.Value, "FAIL Value");
            Assert.IsNull(result.Exception, "FAIL Exception");
        }

        //I: action throwing
        //O: HasError true
        //O: HasException true
        //O: Value exception
        //O: Exception exception
        [TestMethod]
        public void static_Reply_From_action_throwing()
        {
            var result = M.Reply.From(() => Stubs.VoidMethods.PlayInexistentSound());

            Assert.IsTrue(result.HasError, "FAIL HasError");
            Assert.IsTrue(result.HasException, "FAIL HasException");
            Assert.AreSame(Stubs.VoidMethods.EXCEPTION, result.Value, "FAIL Value");
            Assert.AreSame(Stubs.VoidMethods.EXCEPTION, result.Exception, "FAIL Exception");
        }

    }
}

{'fraction_non_alphanumeric': 0.10658771280532939, 'fraction_numerical': 0.0, 'mean_word_length': 1.9313087490961678, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5107449', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1095, 'n_words': 256}