Tmx.TmxHelper.NewTestSuite C# (CSharp) Method

NewTestSuite() public static method

public static NewTestSuite ( string testSuiteName, string testSuiteId, System.Guid testPlatformId, string testSuiteDesctiption, ICodeBlock testSuiteBeforeScenario, ICodeBlock testSuiteAfterScenario ) : bool
testSuiteName string
testSuiteId string
testPlatformId System.Guid
testSuiteDesctiption string
testSuiteBeforeScenario ICodeBlock
testSuiteAfterScenario ICodeBlock
return bool
        public static bool NewTestSuite(string testSuiteName, 
                                        string testSuiteId,
                                        Guid testPlatformId,
                                        string testSuiteDesctiption,
                                        ICodeBlock[] testSuiteBeforeScenario,
                                        ICodeBlock[] testSuiteAfterScenario)
        {
            return TestData.AddTestSuite(testSuiteName,
                                         testSuiteId,
                                         testPlatformId,
                                         testSuiteDesctiption,
                                         testSuiteBeforeScenario,
                                         testSuiteAfterScenario);
        }
        

Usage Example

        internal override void Execute()
        {
            var cmdlet = (NewSuiteCmdletBase)Cmdlet;

            Guid testPlatformId = Guid.Empty;

            if (string.IsNullOrEmpty(cmdlet.TestPlatformId))
            {
                if (null != TestData.CurrentTestPlatform)
                {
                    testPlatformId = TestData.CurrentTestPlatform.UniqueId;
                }
            }

            if (!string.IsNullOrEmpty(cmdlet.TestPlatformId))
            {
                if (TestData.TestPlatforms.All(tp => tp.Id != cmdlet.TestPlatformId))
                {
                    throw new Exception("Couldn't find test platfiorm with Id = " + cmdlet.TestPlatformId);
                }
                testPlatformId = TestData.TestPlatforms.First(tp => tp.Id == cmdlet.TestPlatformId).UniqueId;
            }

            bool result =
                TmxHelper.NewTestSuite(
                    cmdlet.Name,
                    cmdlet.Id,
                    testPlatformId,
                    cmdlet.Description,
                    // 20141211
                    // cmdlet.BeforeScenario,
                    // cmdlet.AfterScenario);
                    // (cmdlet.BeforeScenario.Select(scriptblock => new CodeBlock { Code = scriptblock.ToString() }) ?? new CodeBlock[]{}).ToArray(),
                    // (cmdlet.AfterScenario.Select(scriptblock => new CodeBlock { Code = scriptblock.ToString() }) ?? new CodeBlock[]{}).ToArray());
                    cmdlet.BeforeScenario.Select(scriptblock => new CodeBlock {
                Code = scriptblock.ToString()
            }).ToArray(),
                    cmdlet.AfterScenario.Select(scriptblock => new CodeBlock {
                Code = scriptblock.ToString()
            }).ToArray());

            if (result)
            {
                cmdlet.WriteObject(cmdlet, TestData.CurrentTestSuite);
            }
            else
            {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't create a test suite",
                    "CreatingTestSuite",
                    ErrorCategory.InvalidArgument,
                    true);
            }
        }