Description of UnitTestOutputClass.
Exemplo n.º 1
0
        public void WriteVerbose(PSCmdletBase cmdlet, object obj)
        {
            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }

            string cmdletName   = "? : ";
            string objectString = string.Empty;

            try {
                objectString = obj.ToString();
            }
            catch {}

            if (null != cmdlet)
            {
                try {
                    cmdletName =
                        CmdletSignature(cmdlet);

                    cmdlet.WriteVerbose(cmdletName + objectString);
                }
                catch {
                    cmdlet.WriteVerbose(cmdletName + "failed");
                }
            }
            else
            {
                cmdlet.WriteVerbose(cmdletName + objectString);
            }
        }
Exemplo n.º 2
0
        public virtual void WriteObject(PSCmdletBase cmdlet, string outputObject)
        {
            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }

            writeSingleObject(cmdlet, outputObject);
        }
Exemplo n.º 3
0
        public void WriteObject(PSCmdletBase cmdlet, object outputObject)
        {
            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }

//            cmdlet.WriteVerbose(cmdlet, "outputting the object");

            writeSingleObject(cmdlet, outputObject);
        }
Exemplo n.º 4
0
        public virtual void WriteObject(PSCmdletBase cmdlet, Hashtable outputObjectCollection)
        {
            BeforeWriteCollection(cmdlet, outputObjectCollection);

            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }

            writeSingleObject(cmdlet, outputObjectCollection);

            AfterWriteCollection(cmdlet, outputObjectCollection);
        }
Exemplo n.º 5
0
        void writeSingleError(PSCmdletBase cmdlet, ErrorRecord errorRecord, bool terminating)
        {
//            if (CheckSingleObject(cmdlet, outputObject)) {

//                cmdlet.WriteVerbose(cmdlet, "the output object is not null");

//                WriteObjectMethod020Highlight(cmdlet, outputObject);
//
//                WriteObjectMethod030RunScriptBlocks(cmdlet, outputObject);
//
//                WriteObjectMethod040SetTestResult(cmdlet, outputObject);
//
//                WriteObjectMethod045OnSuccessScreenshot(cmdlet, outputObject);
//
//                WriteObjectMethod050OnSuccessDelay(cmdlet, outputObject);

            // TODO
            // single error
            //BeforeWriteSingleObject(cmdlet, outputObject);

            //WriteSingleObject(cmdlet, outputObject);

            try {
                if (UnitTestMode)
                {
                    UnitTestOutput.Add(errorRecord);
                }
                else
                {
                    //                        WriteObjectMethod060OutputResult(cmdlet, outputObject);
                    WriteSingleError(cmdlet, errorRecord, terminating);
                }
            }
            catch {}

            //WriteObjectMethod060OutputResult(cmdlet, outputObject);

            // TODO
            // single error
            //AfterWriteSingleObject(cmdlet, outputObject);

//                WriteObjectMethod070Report(cmdlet, outputObject);

            //WriteObjectMethod080ReportFailure();

//            } else {
//
//            }
        }
Exemplo n.º 6
0
        public virtual void WriteObject(PSCmdletBase cmdlet, IList outputObjectCollection)
        {
            BeforeWriteCollection(cmdlet, outputObjectCollection);

            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }

            foreach (object item in outputObjectCollection)
            {
                writeSingleObject(cmdlet, item);
            }

            AfterWriteCollection(cmdlet, outputObjectCollection);
        }
Exemplo n.º 7
0
        public virtual void WriteObject(PSCmdletBase cmdlet, object[] outputObjectCollection)
        {
            BeforeWriteCollection(cmdlet, outputObjectCollection);

            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }

            for (int i = 0; i < outputObjectCollection.Length; i++)
            {
                writeSingleObject(cmdlet, outputObjectCollection[i]);
            }

            AfterWriteCollection(cmdlet, outputObjectCollection);
        }
Exemplo n.º 8
0
        void writeSingleObject(PSCmdletBase cmdlet, object outputObject)
        {
            if (CheckSingleObject(cmdlet, outputObject))
            {
                cmdlet.WriteVerbose(cmdlet, "the output object is not null");

//                WriteObjectMethod020Highlight(cmdlet, outputObject);
//
//                WriteObjectMethod030RunScriptBlocks(cmdlet, outputObject);
//
//                WriteObjectMethod040SetTestResult(cmdlet, outputObject);
//
//                WriteObjectMethod045OnSuccessScreenshot(cmdlet, outputObject);
//
//                WriteObjectMethod050OnSuccessDelay(cmdlet, outputObject);

                BeforeWriteSingleObject(cmdlet, outputObject);

                //WriteSingleObject(cmdlet, outputObject);

                try {
                    if (UnitTestMode)
                    {
                        UnitTestOutput.Add(outputObject);
                    }
                    else
                    {
//                        WriteObjectMethod060OutputResult(cmdlet, outputObject);
                        WriteSingleObject(cmdlet, outputObject);
                    }
                }
                catch {}

                //WriteObjectMethod060OutputResult(cmdlet, outputObject);

                AfterWriteSingleObject(cmdlet, outputObject);

//                WriteObjectMethod070Report(cmdlet, outputObject);

                //WriteObjectMethod080ReportFailure();
            }
            else
            {
            }
        }
Exemplo n.º 9
0
        public virtual void WriteObject(PSCmdletBase cmdlet, ICollection outputObjectCollection)
        {
            BeforeWriteCollection(cmdlet, outputObjectCollection);

            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }
            foreach (var outputObject in outputObjectCollection)
            {
// this.WriteVerbose(this, "something to output!!!!!!!!!!1");
                //WriteObject(cmdlet, outputObject);
                writeSingleObject(cmdlet, outputObject);
            }

            AfterWriteCollection(cmdlet, outputObjectCollection);
        }
Exemplo n.º 10
0
        public virtual void WriteObject(PSCmdletBase cmdlet, IEnumerable outputObjectCollection)
        {
            BeforeWriteCollection(cmdlet, outputObjectCollection);

            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }
            IEnumerator en = outputObjectCollection.GetEnumerator();

            while (en.MoveNext())
            {
                writeSingleObject(cmdlet, en.Current);
            }

            AfterWriteCollection(cmdlet, outputObjectCollection);
        }
Exemplo n.º 11
0
        public virtual void WriteObject(PSCmdletBase cmdlet, ArrayList outputObjectCollection)
        {
            BeforeWriteCollection(cmdlet, outputObjectCollection);

            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                //UnitTestOutput.Add(outputObjectCollection);
                UnitTestOutput.StartAddingOutput();
            }

            for (int i = 0; i < outputObjectCollection.Count; i++)
            {
                WriteObject(cmdlet, outputObjectCollection[i]);
            }

            AfterWriteCollection(cmdlet, outputObjectCollection);
        }
Exemplo n.º 12
0
        public virtual void WriteObject(PSCmdletBase cmdlet, List <object> outputObjectCollection)
        {
            BeforeWriteCollection(cmdlet, outputObjectCollection);

            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();

                UnitTestOutput.StartAddingOutput();
            }
            // 20121117
            //for (int i = 0; i < outputObjectCollection.Count; i++) {
            foreach (var item in outputObjectCollection)
            {
                writeSingleObject(cmdlet, item);
            }
            //}

            AfterWriteCollection(cmdlet, outputObjectCollection);
        }
Exemplo n.º 13
0
        public void WriteError(PSCmdletBase cmdlet, string message, string errorId, ErrorCategory category, bool terminating)
        {
            if (UnitTestMode)
            {
                UnitTestOutput.CheckInitialized();
                UnitTestOutput.StartAddingOutput();
            }

            var err =
                new ErrorRecord(
                    new Exception(message),
                    errorId,
                    category,
                    null);

            err.ErrorDetails =
                new ErrorDetails(message);

            //WriteError(cmdlet, err, terminating);
            writeSingleError(cmdlet, err, terminating);
        }