public void EmptyFactory()
        {
            var f = new CodeTaskFactory();

            Assert.AreEqual("Code Task Factory", f.FactoryName, "Name");
            Assert.IsNull(f.TaskType, "TaskType");
            Assert.IsNull(f.CreateTask(null), "CreateTask");
        }
        private void TryLoadTaskBodyAndExpectSuccess(
            string taskBody,
            ICollection <TaskPropertyInfo> parameters = null,
            ISet <string> expectedReferences          = null,
            ISet <string> expectedNamespaces          = null,
            string expectedCodeLanguage = null,
            CodeTaskFactoryCodeType?expectedCodeType = null,
            string expectedSourceCode = null,
            IReadOnlyList <string> expectedWarningMessages = null)
        {
            MockBuildEngine buildEngine = new MockBuildEngine();

            TaskLoggingHelper log = new TaskLoggingHelper(buildEngine, TaskName)
            {
                TaskResources = new ResourceManager(typeof(CodeTaskFactory).GetTypeInfo().Assembly.GetType("RoslynCodeTaskFactory.Properties.Strings"))
            };

            bool success = CodeTaskFactory.TryLoadTaskBody(log, TaskName, taskBody, parameters ?? new List <TaskPropertyInfo>(), out TaskInfo taskInfo);

            buildEngine.Errors.ShouldBe(new string[0]);
            buildEngine.Warnings.ShouldBe(expectedWarningMessages ?? new string[0]);

            Assert.True(success);

            if (expectedReferences != null)
            {
                taskInfo.References.ShouldBe(expectedReferences);
            }

            if (expectedNamespaces != null)
            {
                taskInfo.Namespaces.ShouldBe(expectedNamespaces);
            }

            if (expectedCodeLanguage != null)
            {
                taskInfo.CodeLanguage.ShouldBe(expectedCodeLanguage);
            }

            if (expectedCodeType != null)
            {
                taskInfo.CodeType.ShouldBe(expectedCodeType.Value);
            }

            if (expectedSourceCode != null)
            {
                taskInfo.SourceCode.ShouldBe(expectedSourceCode, StringCompareShould.IgnoreLineEndings);
            }
        }
        private void TryLoadTaskBodyAndExpectFailure(string taskBody, string expectedErrorMessage)
        {
            if (expectedErrorMessage == null)
            {
                throw new ArgumentNullException(nameof(expectedErrorMessage));
            }

            MockBuildEngine buildEngine = new MockBuildEngine();

            TaskLoggingHelper log = new TaskLoggingHelper(buildEngine, TaskName)
            {
                TaskResources = new ResourceManager(typeof(CodeTaskFactory).GetTypeInfo().Assembly.GetType("RoslynCodeTaskFactory.Strings"))
            };

            bool success = CodeTaskFactory.TryLoadTaskBody(log, TaskName, taskBody, new List <TaskPropertyInfo>(), out TaskInfo _);

            Assert.False(success);

            buildEngine.Errors.ShouldBe(new[] { expectedErrorMessage });
        }