简体   繁体   English

在使用C#运行测试之前,先修改fitnesse文本框中的字符串

[英]Modifying the strings in fitnesse textbox before running the tests using C#

Bear with me guys because I don't know how to start things up using fitNesse framework. 忍受我吧,因为我不知道如何使用fitNesse框架来启动。

okay here's where I need help, upon running the test I want to capture the string or the fitnesse scripts being placed in the fitnesse textarea and then a certain function will then parse the scripts to replace the strings I want to replace. 好的,这是我需要帮助的地方,在运行测试后,我想捕获字符串或fitnesse文本区域中放置的fitnesse脚本,然后某个函数将解析脚本以替换我要替换的字符串。 For example, I'd like to replace all the 'today' text in the scipts with the real DateTime today. 例如,我想用真实的DateTime替换Scipts中的所有“今天”文本。

actually my purpose of doing this its because not only using it in parsing 'todays date' but instead including parsing tomorrow, yesterday and a 'basedate' variable at the top of each test. 实际上,我这样做的目的是因为它不仅用于解析“今天的日期”,而且包括解析明天,昨天和每个测试顶部的“基于”变量。 Much of its use will be on assigning the 'basedate' functionality. 它的大部分用途是分配“基于”功能。

I then created a class named 'DateFunctions' which parses the text in the text area not just looking for the 'today' keyword but also including parsing tomorrow, yesterday 然后,我创建了一个名为“ DateFunctions”的类,该类不仅分析“ today”关键字,而且还分析明天的昨天文本区域中的文本。

my new question will be, is my new implementation below makes sense or is correct perhaps? 我的新问题将是,下面的新实现是否有意义或正确? and is there a way on how to debug C# codes in fitnesse? 有没有办法在fitnesse中调试C#代码?

public class RowFixtureBase : fit.RowFixture
    {
        public virtual void setBaseDate(String basedate)
        {
            if (!DateFunctions.SetBaseDateTo(basedate))
            {
                throw new ArgumentException();
            }
        }

        public override void DoRow(fit.Parse rows)
        {
            foreach (fit.Parse row in new fitlibrary.ParseEnumerator(rows))
            {
                fit.Parse newrow = new fit.Parse(DateFunctions.EvaluateDate(row.Text));
                base.DoRow(newrow);
            }
        }

        //more codes here that is irrelevant to the question
    }

With the latest versions of FitNesse, you should be able to use !today as markup in the FitNesse page. 使用最新版本的FitNesse,您今天应该可以在FitNesse页面上使用!today作为标记。 So your specific example may already be implemented for you. 因此,您的特定示例可能已经为您实现了。

http://fitnesse.org/FitNesse.UserGuide.TodaysDate http://fitnesse.org/FitNesse.UserGuide.TodaysDate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM