public void SetUp()
		{
			_dirPath = Guid.NewGuid().ToString();
			_filePath = string.Format("{0}{1}{2}", _dirPath, Path.DirectorySeparatorChar, Guid.NewGuid());
			_formatter = MockRepository.GenerateMock<IResultFormatter>();
			_subject = new SummaryFileWriter(_formatter, _filePath);
		}
Exemple #2
0
 public CommandGeneric(IQCollectionRetriever <T1> qcollectionRetriever, ICommand <T1, T2> oneInfo, IResultFormatter format, IConnectionWrapper api = null)
 {
     QCollectionRetriever = qcollectionRetriever;
     OneElementLauncher   = oneInfo;
     FormatToString       = format;
     this.API             = api ?? new ConnectionWrapper();
 }
Exemple #3
0
 public CommandGenericOneElem(IQElementRetriever <T1> qelementRetriever, ICommand <T1, T2> getInfo, IResultFormatter formatter, IConnectionWrapper api = null)
 {
     this.QElementRetriever = qelementRetriever;
     this.ElementLauncher   = getInfo;
     this.Formatter         = formatter;
     this.API = api ?? new ConnectionWrapper();
 }
Exemple #4
0
 public void SetUp()
 {
     _dirPath   = Guid.NewGuid().ToString();
     _filePath  = string.Format("{0}{1}{2}", _dirPath, Path.DirectorySeparatorChar, Guid.NewGuid().ToString());
     _formatter = MockRepository.GenerateMock <IResultFormatter>();
     _subject   = new SummaryFileWriter(_formatter, _filePath);
 }
        protected IResultFormatter CreateFormatter(FormatterType type, FileInfo outfile)
        {
            IResultFormatter retFormatter = null;

            switch (type)
            {
            case FormatterType.Plain:
                retFormatter = (IResultFormatter) new PlainTextFormatter();
                break;

            case FormatterType.Xml:
                retFormatter = (IResultFormatter) new XmlResultFormatter();
                break;

            default:
                break;
            }

            if (outfile == null)
            {
                // TO-DO : find solution for creating LogWriter without access to Task or Project
                // for dispatching logging events
                // retFormatter.SetOutput(new LogWriter());
                retFormatter.SetOutput(Console.Out);
            }
            else
            {
                retFormatter.SetOutput(new StreamWriter(outfile.Create()));
            }
            return(retFormatter);
        }
Exemple #6
0
 internal ResultAttribute(ResultAttributeBuilder builder)
 {
     _name       = builder.Name ?? string.Empty;
     Valid       = builder._valid;
     _attributes = new List <IResultAttribute>(builder._attributes).AsReadOnly();
     _value      = builder.Value;
     _formatter  = builder.Formatter ?? DefaultResultFormatter;
 }
Exemple #7
0
        /// <summary>
        /// Starts writing results
        /// </summary>
        protected override void StartResultsInternal()
        {
            if (this._closeOnEnd && this._writer == null)
            {
                throw new RdfParseException("Cannot use this ResultWriteThroughHandler as an Results Handler for parsing as you set closeOnEnd to true and you have already used this Handler and so the provided TextWriter was closed");
            }
            this._currentType = SparqlResultsType.Unknown;
            this._currVariables.Clear();
            this._headerWritten = false;

            if (this._formatterType != null)
            {
                this._formatter        = null;
                this._formattingMapper = new QNameOutputMapper();

                // Instantiate a new Formatter
                ConstructorInfo[] cs = this._formatterType.GetConstructors();
                Type qnameMapperType = typeof(QNameOutputMapper);
                Type nsMapperType    = typeof(INamespaceMapper);
                foreach (ConstructorInfo c in cs.OrderByDescending(c => c.GetParameters().Count()))
                {
                    ParameterInfo[] ps = c.GetParameters();
                    try
                    {
                        if (ps.Length == 1)
                        {
                            if (ps[0].ParameterType.Equals(qnameMapperType))
                            {
                                this._formatter = Activator.CreateInstance(this._formatterType, new Object[] { this._formattingMapper }) as IResultFormatter;
                            }
                            else if (ps[0].ParameterType.Equals(nsMapperType))
                            {
                                this._formatter = Activator.CreateInstance(this._formatterType, new Object[] { this._formattingMapper }) as IResultFormatter;
                            }
                        }
                        else if (ps.Length == 0)
                        {
                            this._formatter = Activator.CreateInstance(this._formatterType) as IResultFormatter;
                        }

                        if (this._formatter != null)
                        {
                            break;
                        }
                    }
                    catch
                    {
                        // Suppress errors since we'll throw later if necessary
                    }
                }

                // If we get out here and the formatter is null then we throw an error
                if (this._formatter == null)
                {
                    throw new RdfParseException("Unable to instantiate a IResultFormatter from the given Formatter Type " + this._formatterType.FullName);
                }
            }
        }
Exemple #8
0
 public Game(IGameboard gameboard,
             ICommandPathReducer commandReducer,
             ICommandToCoordinateMapper commandToCoordinateMapper,
             IResultFormatter resultFormatter)
 {
     _gameboard                 = gameboard;
     _commandReducer            = commandReducer;
     _commandToCoordinateMapper = commandToCoordinateMapper;
     _resultFormatter           = resultFormatter;
 }
Exemple #9
0
        private static void PrintResult(IEnumerable<ResultDataItem> items, IResultFormatter formatter)
        {
            //header
            Console.WriteLine(formatter.GetHeader());

            //detail
            foreach (var item in items)
            {
                Console.WriteLine(formatter.GetDetail(item));
            }
        }
        /// <summary>
        /// Creates a new attribute with the given <paramref name="format"/> string.
        /// For example, use <c>"{0:X8}"</c> for hexadecimal number formatting.
        /// </summary>
        /// <param name="attributeName">the name for the attribute</param>
        /// <param name="value">the initial value of the attribute</param>
        /// <param name="format">the format string</param>
        ///
        public FormattedAttribute(TEnum attributeName, TValue value, string format)
            : base(attributeName, value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            _formatter = new StringResultFormatter(format);
        }
        public FormattedAttribute(TEnum attributeName, TValue value, IResultFormatter formatter)
            : base(attributeName, value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (formatter == null)
            {
                throw new ArgumentNullException("formatter");
            }

            _formatter = formatter;
        }
Exemple #12
0
 /// <summary>
 /// Creates a new Write-Through Handler
 /// </summary>
 /// <param name="formatter">Triple Formatter to use</param>
 /// <param name="writer">Text Writer to write to</param>
 /// <param name="closeOnEnd">Whether to close the writer at the end of RDF handling</param>
 public ResultWriteThroughHandler(IResultFormatter formatter, TextWriter writer, bool closeOnEnd)
 {
     if (writer == null) throw new ArgumentNullException("writer", "Cannot use a null TextWriter with the Result Write Through Handler");
     if (formatter != null)
     {
         this._formatter = formatter;
     }
     else
     {
         this._formatter = new NTriplesFormatter();
     }
     this._writer = writer;
     this._closeOnEnd = closeOnEnd;
 }
        public void AddAttribute <TName>(TName name, object value, IResultFormatter formatter)
        {
            var attribute = new FormattedAttribute <TName, object>(name, value, formatter);

            var validityResultFormatter = formatter as IValidityResultFormatter;

            if ((validityResultFormatter != null) && !validityResultFormatter.IsValid(value))
            {
                attribute.Valid = false;

                Invalidate();
            }

            _resultBuilder.AddAttribute(attribute);
        }
        public DocumentDataExtractionUserControl()
        {
            InitializeComponent();

            var serviceProvider = DependencyResolver.GetServices().BuildServiceProvider();

            documentDataBusinessLogic = serviceProvider.GetService <IDocumentDataBusinessLogic>();
            resultFormatter           = serviceProvider.GetService <IResultFormatter>();

            documentDataDisplayUserControl = new DocumentDataDisplayUserControl();
            panelDocumentDataDisplayUserControl.Controls.Add(documentDataDisplayUserControl);

            UpdateRunButtonEnabledProperty();
            SetStatusLabel("Waiting for input", Color.DodgerBlue);
        }
Exemple #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RatedResult"/> class.
 /// </summary>
 /// <param name="movesCount">Count of moves</param>
 /// <param name="playerName">Name of the player</param>
 /// <param name="formatter">ToString() result formatter</param>
 public RatedResult(int movesCount, string playerName, IResultFormatter formatter)
     : base(movesCount, playerName, formatter)
 {
     if (movesCount <= (int)PlayerRating.Master)
     {
         this.Rating = PlayerRating.Master;
     }
     else if (movesCount <= (int)PlayerRating.Player)
     {
         this.Rating = PlayerRating.Player;
     }
     else
     {
         this.Rating = PlayerRating.Beginner;
     }
 }
Exemple #16
0
        public void ReadAndConvert()
        {
            PaySlipCalculator mokPaySlipCalculator = Substitute.For <PaySlipCalculator>();
            IResultFormatter  mokIResultFormatter  = Substitute.For <IResultFormatter>();

            mokIResultFormatter.ReadConvert(Arg.Any <string>()).Returns(new List <string> {
                "David,Rudd,60050,9%,01 March - 31 March", "Ryan,Chen,120000,10%,01 March - 31 March"
            });
            var expect = new List <string> {
                "David Rudd,01 March - 31 March,5004,922,4082,450", "Ryan Chen,01 March - 31 March,10000,2696,7304,1000"
            };

            var sut = mokPaySlipCalculator.Convert(mokIResultFormatter.ReadConvert(""));

            Assert.AreEqual(sut[0], expect[0]);
            Assert.AreEqual(sut[1], expect[1]);
        }
Exemple #17
0
 /// <summary>
 /// Creates a new Write-Through Handler
 /// </summary>
 /// <param name="formatter">Triple Formatter to use</param>
 /// <param name="writer">Text Writer to write to</param>
 /// <param name="closeOnEnd">Whether to close the writer at the end of RDF handling</param>
 public ResultWriteThroughHandler(IResultFormatter formatter, TextWriter writer, bool closeOnEnd)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer", "Cannot use a null TextWriter with the Result Write Through Handler");
     }
     if (formatter != null)
     {
         this._formatter = formatter;
     }
     else
     {
         this._formatter = new NTriplesFormatter();
     }
     this._writer     = writer;
     this._closeOnEnd = closeOnEnd;
 }
        /// <summary>
        /// Creates the formatters to be used when running this test.
        /// </summary>
        protected void CreateFormatters(NUnitTestData testData, string logPrefix, bool verbose)
        {
            // Now add the specified formatters
            foreach (FormatterData formatterData in testData.Formatters)
            {
                // determine file
                FileInfo         outFile   = GetOutput(formatterData, testData);
                IResultFormatter formatter = CreateFormatter(formatterData.Type, outFile);
                Formatters.Add(formatter);
            }
            // Add default formatter
            // The Log formatter is special in that it always writes to the
            // Log class rather than the TextWriter set in SetOutput().
            // HACK!
            LogFormatter logFormatter = new LogFormatter(logPrefix, verbose);

            Formatters.Add(logFormatter);
        }
		public void SetUp()
		{
			_filePath = Guid.NewGuid().ToString();
			_formatter = MockRepository.GenerateMock<IResultFormatter>();
			_subject = new FeatureSummaryAggregator(_formatter, _filePath);
		}
 /// <summary>
 /// Adds the elements of a <see cref="IResultFormatter"/> array to the end of the collection.
 /// </summary>
 /// <param name="items">The array of <see cref="IResultFormatter"/> elements to be added to the end of the collection.</param> 
 public void AddRange(IResultFormatter[] items) {
     for (int i = 0; (i < items.Length); i = (i + 1)) {
         Add(items[i]);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IResultFormatterCollection"/> class
 /// with the specified array of <see cref="IResultFormatter"/> instances.
 /// </summary>
 public IResultFormatterCollection(IResultFormatter[] value) {
     AddRange(value);
 }
 /// <summary>
 /// Inserts a <see cref="IResultFormatter"/> into the collection at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
 /// <param name="item">The <see cref="IResultFormatter"/> to insert.</param>
 public void Insert(int index, IResultFormatter item) {
     base.List.Insert(index, item);
 }
 /// <summary>
 /// Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.        
 /// </summary>
 /// <param name="array">The one-dimensional array that is the destination of the elements copied from the collection. The array must have zero-based indexing.</param> 
 /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param>
 public void CopyTo(IResultFormatter[] array, int index) {
     base.List.CopyTo(array, index);
 }
		/// <summary>
		/// Constructor allowing to specify result formatter and output file path. 
		/// </summary>
		/// <param name="resultFormatter">Formatter.</param>
		/// <param name="filePath">Output file path.</param>
		public FeatureSummaryAggregator(IResultFormatter resultFormatter, string filePath)
		{
			_summary = new TestResultsSummary(resultFormatter);
			FilePath = filePath;
		}
 public void SetUp()
 {
     _formatter = MockRepository.GenerateMock <IResultFormatter>();
     _subject   = new TestResultsSummary(_formatter);
 }
Exemple #26
0
 /// <summary>
 /// Retrieves the index of a specified <see cref="IResultFormatter"/> object in the collection.
 /// </summary>
 /// <param name="item">The <see cref="IResultFormatter"/> object for which the index is returned.</param>
 /// <returns>
 /// The index of the specified <see cref="IResultFormatter"/>. If the <see cref="IResultFormatter"/> is not currently a member of the collection, it returns -1.
 /// </returns>
 public int IndexOf(IResultFormatter item)
 {
     return(base.List.IndexOf(item));
 }
Exemple #27
0
 /// <summary>
 /// Determines whether a <see cref="IResultFormatter"/> is in the collection.
 /// </summary>
 /// <param name="item">The <see cref="IResultFormatter"/> to locate in the collection.</param>
 /// <returns>
 /// <see langword="true" /> if <paramref name="item"/> is found in the
 /// collection; otherwise, <see langword="false" />.
 /// </returns>
 public bool Contains(IResultFormatter item)
 {
     return(base.List.Contains(item));
 }
Exemple #28
0
 public LauncherFactory(IResultFormatter format, IConnectionWrapper connectWrapper)
 {
     Formatter         = format;
     ConnectionWrapper = connectWrapper;
 }
Exemple #29
0
 public void Initialize()
 {
     _paySlipCalculator = new PaySlipCalculator();
     _resultFormatter   = new TextFileFormatter();
 }
Exemple #30
0
 public StreamInfoAttributeParser()
 {
     _streamInfoResultFormatter = new StringResultFormatter("{0:X2}");
 }
 /// <summary>
 /// Constructor allowing to define formatter type.
 /// </summary>
 /// <param name="formatter">Results formatter.</param>
 public TestResultsSummary(IResultFormatter formatter)
 {
     _formatter = formatter;
 }
 public void SetUp()
 {
     _subject = new XmlResultFormatter();
 }
 public ConsoleRenderer(IResultFormatter formatter, IWriter writer)
     : base(formatter, writer)
 {
 }
Exemple #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Renderer"/> class.
 /// </summary>
 /// <param name="formatter">Instance of IResultFormatter</param>
 /// <param name="writer">Instance of IWriter</param>
 protected Renderer(IResultFormatter formatter, IWriter writer)
 {
     this.Formatter = formatter;
     this.Writer = writer;
 }
Exemple #35
0
 public void SetUp()
 {
     _filePath  = Guid.NewGuid().ToString();
     _formatter = MockRepository.GenerateMock <IResultFormatter>();
     _subject   = new FeatureSummaryAggregator(_formatter, _filePath);
 }
 public void SetUp()
 {
     _subject = new PlainTextResultFormatter();
 }
Exemple #37
0
 /// <summary>
 /// Removes a member from the collection.
 /// </summary>
 /// <param name="item">The <see cref="IResultFormatter"/> to remove from the collection.</param>
 public void Remove(IResultFormatter item)
 {
     base.List.Remove(item);
 }
 /// <summary>
 /// Determines whether a <see cref="IResultFormatter"/> is in the collection.
 /// </summary>
 /// <param name="item">The <see cref="IResultFormatter"/> to locate in the collection.</param> 
 /// <returns>
 /// <see langword="true" /> if <paramref name="item"/> is found in the 
 /// collection; otherwise, <see langword="false" />.
 /// </returns>
 public bool Contains(IResultFormatter item) {
     return base.List.Contains(item);
 }
Exemple #39
0
 /// <summary>
 /// Creates a new Write-Through Handler
 /// </summary>
 /// <param name="formatter">Triple Formatter to use</param>
 /// <param name="writer">Text Writer to write to</param>
 public ResultWriteThroughHandler(IResultFormatter formatter, TextWriter writer)
     : this(formatter, writer, true)
 {
 }
 /// <summary>
 /// Retrieves the index of a specified <see cref="IResultFormatter"/> object in the collection.
 /// </summary>
 /// <param name="item">The <see cref="IResultFormatter"/> object for which the index is returned.</param> 
 /// <returns>
 /// The index of the specified <see cref="IResultFormatter"/>. If the <see cref="IResultFormatter"/> is not currently a member of the collection, it returns -1.
 /// </returns>
 public int IndexOf(IResultFormatter item) {
     return base.List.IndexOf(item);
 }
Exemple #41
0
 /// <summary>
 /// Creates a new Write-Through Handler
 /// </summary>
 /// <param name="formatter">Triple Formatter to use</param>
 /// <param name="writer">Text Writer to write to</param>
 public ResultWriteThroughHandler(IResultFormatter formatter, TextWriter writer)
     : this(formatter, writer, true)
 {
 }
 /// <summary>
 /// Removes a member from the collection.
 /// </summary>
 /// <param name="item">The <see cref="IResultFormatter"/> to remove from the collection.</param>
 public void Remove(IResultFormatter item) {
     base.List.Remove(item);
 }
Exemple #43
0
        /// <summary>
        /// Starts writing results
        /// </summary>
        protected override void StartResultsInternal()
        {
            if (this._closeOnEnd && this._writer == null) throw new RdfParseException("Cannot use this ResultWriteThroughHandler as an Results Handler for parsing as you set closeOnEnd to true and you have already used this Handler and so the provided TextWriter was closed");
            this._currentType = SparqlResultsType.Unknown;
            this._currVariables.Clear();
            this._headerWritten = false;

            if (this._formatterType != null)
            {
                this._formatter = null;
                this._formattingMapper = new QNameOutputMapper();

                //Instantiate a new Formatter
                ConstructorInfo[] cs = this._formatterType.GetConstructors();
                Type qnameMapperType = typeof(QNameOutputMapper);
                Type nsMapperType = typeof(INamespaceMapper);
                foreach (ConstructorInfo c in cs.OrderByDescending(c => c.GetParameters().Count()))
                {
                    ParameterInfo[] ps = c.GetParameters();
                    try
                    {
                        if (ps.Length == 1)
                        {
                            if (ps[0].ParameterType.Equals(qnameMapperType))
                            {
                                this._formatter = Activator.CreateInstance(this._formatterType, new Object[] { this._formattingMapper }) as IResultFormatter;
                            }
                            else if (ps[0].ParameterType.Equals(nsMapperType))
                            {
                                this._formatter = Activator.CreateInstance(this._formatterType, new Object[] { this._formattingMapper }) as IResultFormatter;
                            }
                        }
                        else if (ps.Length == 0)
                        {
                            this._formatter = Activator.CreateInstance(this._formatterType) as IResultFormatter;
                        }

                        if (this._formatter != null) break;
                    }
                    catch
                    {
                        //Suppress errors since we'll throw later if necessary
                    }
                }

                //If we get out here and the formatter is null then we throw an error
                if (this._formatter == null) throw new RdfParseException("Unable to instantiate a IResultFormatter from the given Formatter Type " + this._formatterType.FullName);
            }
        }
 /// <summary>
 /// Adds a <see cref="IResultFormatter"/> to the end of the collection.
 /// </summary>
 /// <param name="item">The <see cref="IResultFormatter"/> to be added to the end of the collection.</param> 
 /// <returns>The position into which the new element was inserted.</returns>
 public int Add(IResultFormatter item) {
     return base.List.Add(item);
 }
 public void SetUp()
 {
     _formatter = MockRepository.GenerateMock<IResultFormatter>();
     _subject = new TestResultsSummary(_formatter);
 }
Exemple #46
0
 /// <summary>
 /// Adds a <see cref="IResultFormatter"/> to the end of the collection.
 /// </summary>
 /// <param name="item">The <see cref="IResultFormatter"/> to be added to the end of the collection.</param>
 /// <returns>The position into which the new element was inserted.</returns>
 public int Add(IResultFormatter item)
 {
     return(base.List.Add(item));
 }
 internal TimeCodeAttribute()
 {
     _timeCodeResultFormatter = new TimeCodeResultFormatter();
 }
Exemple #48
0
 public void SetUp()
 {
     _subject = new XmlResultFormatter();
 }
Exemple #49
0
 public TextFileResultSaver(string outputFileName, IResultFormatter resultFormatter)
 {
     _outputFileName  = outputFileName;
     _resultFormatter = resultFormatter;
 }
 /// <summary>
 /// Constructor allowing to create SummaryFileWriter with associated result formatter and output path.
 /// </summary>
 /// <param name="formatter">Result formatter.</param>
 /// <param name="outputPath">Output path.</param>
 public SummaryFileWriter(IResultFormatter formatter, string outputPath)
 {
     _outputPath = Path.GetFullPath(outputPath);
     _formatter = formatter;
 }
Exemple #51
0
 public WpfRenderer(IResultFormatter formatter, IWriter writer)
     : base(formatter, writer)
 {
 }
Exemple #52
0
 /// <summary>
 /// Inserts a <see cref="IResultFormatter"/> into the collection at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
 /// <param name="item">The <see cref="IResultFormatter"/> to insert.</param>
 public void Insert(int index, IResultFormatter item)
 {
     base.List.Insert(index, item);
 }
Exemple #53
0
 public void SetUp()
 {
     _subject = new PlainTextResultFormatter();
 }