实习程序员求助-接口与类

qq5296161 2014-10-25 03:54:10
大叫好好,我是一名在校生,现在在一家软件公司做软件测试的实习生,现在经理给了我个任务,我不会,但是也强忍着接下来了,想请C#高手帮忙,应该不会太难,主要是自己不会...
这个是写类做接口的任务,现在的情况:提供了一个项目提供了一个以vs2012 .net4 开发的的解决方案SmokeTestSet.sln. 里面有这个项目的基本代码,任务是:已经有人把类图画好其中有各个类名,和方法。
如下:
一、IConfig接口下有两个方法getStartURL和getTargetWebBrowser,前者是传递Web地址,后者是传递浏览器类型。在IConfig下有两个类,一个XMLConfig和FileConfig,就是说通过这两个类去到XML和File里去抓取配置文件,抓取的内容也是URL和WebBrowser,在BrowserType和ConfigFileType里是枚举型的类型(这个专业术语叫什么?实例?)
IConfig接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SeleniumTools
{
public interface IConfig
{
/// <summary>
/// 待测Web应用起始网址
/// </summary>
/// <returns>URL</returns>
string getStartURL();

/// <summary>
/// 执行测试目标浏览器
/// </summary>
/// <returns>BrowserType枚举类型</returns>
BrowserType getTargetWebBrowser();
}
}

XMLConfig类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SeleniumTools
{
public class XMLConfig : IConfig
{
public string getStartURL()
{
throw new NotImplementedException();
}

public BrowserType getTargetWebBrowser()
{
throw new NotImplementedException();
}
}
}


FileConfig类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SeleniumTools
{
public class FileConfig : IConfig
{
public string getStartURL()
{
throw new NotImplementedException();
}

public BrowserType getTargetWebBrowser()
{
throw new NotImplementedException();
}
}
}

二、ITestData接口是为了传递测试数据,你可一看到,方法是getAll(获取全部测试数据), getCount(获取测试数据的数量),getFirst(获取测试数据第一个值),Next(获取下一个测试数据)。在接口下的三个类是ExcelTestDate,FileTestData,XMLTestDate,就是从三类文件里抓取测试数据用接口传递出去。
ITestData接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace SeleniumTools
{
public class TestData
{
/// <summary>
/// 根据参数名获取该参数名下有多少可用值
/// </summary>
/// <remarks>若参数名未找到则抛出ParameterNameNotFound异常</remarks>
/// <returns>该参数名下可用参数值个数</returns>
public int getCount(string parameterName)
{
throw new System.NotImplementedException();
}

/// <summary>
/// 根据参数名获取该参数名下第一个可用值
/// </summary>
/// <remarks>若参数名未找到则抛出ParameterNameNotFound异常</remarks>
/// <returns>第一个可用值,若该参数名下无可用值,则返回空字符串</returns>
public string getFirst(string parameterName)
{
throw new System.NotImplementedException();
}

/// <summary>
/// 根据参数名获取下一个可用值
/// </summary>
/// <remarks>若参数名未找到则抛出ParameterNameNotFound异常</remarks>
/// <returns>返回下一个可用值</returns>
public string Next(string parameterName)
{
throw new System.NotImplementedException();
}

/// <summary>
/// 根据参数名获取该参数名下所有可用值
/// </summary>
/// <remarks>若参数名未找到则抛出ParameterNameNotFound异常</remarks>
/// <returns>返回参数可用值List</returns>
public List getAll(string parameterName)
{
throw new System.NotImplementedException();
}
}

public interface ITestData
{
/// <summary>
/// 根据参数名获取该参数名下所有可用值
/// </summary>
/// <remarks>若参数名未找到则抛出ParameterNameNotFound异常</remarks>
/// <returns>返回参数可用List</returns>
List getAll(string parameterName);

/// <summary>
/// 根据参数名获取该参数名下有多少可用值
/// </summary>
/// <remarks>若参数名未找到则抛出ParameterNameNotFound异常</remarks>
/// <returns>该参数名下可用参数个数</returns>
int getCount(string parameterName);

/// <summary>
/// 根据参数名获取该参数名下第一个可用值
/// </summary>
/// <remarks>若参数名未找到则抛出ParameterNameNotFound异常</remarks>
/// <returns>第一个可用值,若该参数名下无可用值,则返回空字符串</returns>
string getFirst(string parameterName);

/// <summary>
/// 根据参数名获取下一个可用值
/// </summary>
/// <remarks>若参数名未找到则抛出ParameterNameNotFound异常</remarks>
/// <returns>返回下一个可用值</returns>
string Next(string parameterName);
}
}


XMLTestData

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace SeleniumTools
{
public class XMLTestData : ITestData
{
public List getAll(string parameterName)
{
throw new NotImplementedException();
}

public int getCount(string parameterName)
{
throw new NotImplementedException();
}

public string getFirst(string parameterName)
{
throw new NotImplementedException();
}

public string Next(string parameterName)
{
throw new NotImplementedException();
}
}
}

三、在类图里还有一个类叫SeleniumToolFactory,这个我不太懂了,好像是什么工厂化设计模式下面两个方法,getConfigFactory和getTestDataFactory, 我看到这两个方法的返回类型是IConfig和ITestData. 我认为这个Class是最初的入口,然后去调用2个接口,接口再去获取相应的Cinfig和TestData。
SeleniumToolFactory

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace SeleniumTools
{
public class XMLTestData : ITestData
{
public List getAll(string parameterName)
{
throw new NotImplementedException();
}

public int getCount(string parameterName)
{
throw new NotImplementedException();
}

public string getFirst(string parameterName)
{
throw new NotImplementedException();
}

public string Next(string parameterName)
{
throw new NotImplementedException();
}
}
}


具体要做的就这么多,但是真心不会
他们说最终目的是需要生成一个dll,然后以后需要这样做自动化测试的时候就直接调用这个dll。

各位大大,帮我看看吧,
万分感谢,必高分回报。
我附上项目的文件。
...全文
376 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
junehuang111 2014-10-26
  • 打赏
  • 举报
回复
进来学习一下 。
qq5296161 2014-10-25
  • 打赏
  • 举报
回复
嗯,谢谢提醒。不过环境确实不好。想到这个是经理直接安排的,想好好完成下,思路理清了但是又不知道该怎么写,大大有什么推荐的相关资料嘛。
qq5296161 2014-10-25
  • 打赏
  • 举报
回复
谢谢,我就是想找人学习。
qq5296161 2014-10-25
  • 打赏
  • 举报
回复
就是不会,唉,工作环境很恶心,没人教,又不敢问那个经理,他一个劲的说简单,大学的时候也学过这个,但是基本都是丢包谷了。想在csdn找人学习。思路我还是挺清楚的,只是这个写代码到底该则么做,或者说怎么开始就不清楚了,以前写的程序都很简单。
threenewbee 2014-10-25
  • 打赏
  • 举报
回复
这个和接口没什么关系,关键还是写代码,只是你的代码符合接口的输入输出而已。 难道程序员不就是干写代码的事情的么?
winnowc 2014-10-25
  • 打赏
  • 举报
回复
这其实就是配置有两种方式保存,测试数据有三种方式保存,你需要做的是把那些throw new NotImplementedException();全部按需求写成代码。这估计没人能帮你了。
  • 打赏
  • 举报
回复
培训你,是公司的任务。 实习生在半年内做不了什么,就是跟公司学习的。不要上那种动不动只会让你上csdn的公司实习。

662

社区成员

发帖
与我相关
我的任务
社区描述
提出问题
其他 技术论坛(原bbs)
社区管理员
  • community_281
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧