chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Is it possible to test a private static method (extension method).

I am having little to no luck on finding a workable solution.

I would like to test the following passing a fake instance:

    public static class XBRLExtensions
        private static DateTime StartDate(this Instance instance)
            var itm = instance.GetItemByName(Resources.PeriodStartDateFieldName);

            return DateTime.Parse(itm.SpecifiedValue);

any help would be greatly appreciated :)
asked by Squid (3.5k points)

1 Answer

0 votes
I got it to work using a private accessor.

I couldn't get the accessor working yesterday... so today I wiped it out and started again and all works as expected.
        public void StartDateTest()
            var instance = Isolate.Fake.Instance<Instance>();
            DateTime expected = new DateTime(); // TODO: Initialize to an appropriate value
            DateTime actual;
            actual = XBRLExtensions_Accessor.StartDate(instance);
            Assert.AreEqual(expected, actual);
answered by Squid (3.5k points)