我在MacOSX10.9.4、NUnit 2.6.3和FakeItEasy 1.23.0上使用Xamarin Studio5.2。
当我为这段代码运行测试时:
using System;
using ValueSet = System.Collections.Generic.HashSet<uint>;
using NUnit.Framework;
using FakeItEasy;
namespace SetTest
{
[TestFixture]
class TestFixture
{
[Test]
public voi
我想测试我的空存储库。我的服务班是这样的。
public class AccountService
{
private readonly IAccountRepository accountRepository;
public AccountService(IAccountRepository accountRepository)
{
this.accountRepository = accountRepository;
}
public User GetById(string userId)
{
User u
我试图对“服务层”/“应用程序外观层”方法进行单元测试。这是我尝试单元测试的方法:
// Create a new order in the database for a customer. Given a customer id,
// will create a new order and return an OrderDto for use in the presentation
// layer.
public OrderDto CreateOrderForCustomer(int customerId)
{
// Find the customer
var customer
我有一个关于FakeItEasy (或者其他模拟对象的问题,因为我相信它们非常相似)。以下是我的puesdocode:
public class Service
{
public void CheckService()
{
...
Status status;
if (Getboolean)
{
status = Status.Pass;
}
else
{
status = Status.NotPass;
考虑下面的界面..。
public interface MyInterface
{
bool MyProperty { get; }
}
我试图在get中对该属性的函数进行存根处理。
[Test]
public void Foo()
{
var fake = A.Fake<MyInterface>();
var sut = new MySUT(fake);
A.CallTo(() => fake.MyProperty).Returns(true);
var result = sut.Foo();
Assert.IsTrue(
假设我有一个接口
public interface IDatabase
{
IObjectSet<Table1> Table1 {get;}
IObjectSet<Table2> Table2 {get;}
//goes on to around Table400
}
因此,当我用FakeItEasy创建一个实例时:
var fakeDb = A.Fake<IDatabase>();
所有属性(表)都有一个缺省假值。我能理解为什么这在大多数塞纳里奥斯人中很方便,但在我的,我需要他们都是null。
有什么聪明的方法吗?
我想用简单的喷射器做一些集成测试。但是,有时我需要检查是否使用正确的参数调用了特定的内部服务。我已经在测试项目中使用了FakeItEasy,所以我的方法是这样做:
container.Options.RegisterResolveInterceptor(
(context, producer) =>
{
// this is the instance as it was provided by the container
object instance = producer();
object spy = FakeItEa
我对FakeItEasy很陌生,一般都是在嘲笑别人。我创建了一个Visual 2010 C#类库项目。我添加了对NUnit DLL和FakeItEasy DLL的引用。我为这两种语言添加了“使用”语句,然后尝试了一些文档示例。我的代码是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FakeItEasy.Core;
// ...
using NUnit.Framework;
namespace TestLib
{
[TestFixture]
将m设为std::smatch类型。假设有一个无与伦比的组i。m.position(i)是什么?在这个问题上,什么是m[i]?
例如,考虑
std::regex re {"^(a+)|(b+)"};
string target="aa";
std::smatch m;
std::regex_search(target,m,re);
cout<<"m[2] is: "<<m[2]<<" at position: "<<m.position(2);
我无法从参考中弄清楚这里肯定会发生什么
我想重设一个假电话历史或忽略一个电话。
假断言方法在测试类构造函数中的Init方法中被调用,我想忽略这个调用,因为它不是测试操作的一部分。
这里有一个例子:
[TestClass]
public class UnitTest1
{
private MyFakedClass myFakedObject;
private SUT sut;
[TestInitialize]
public void Init()
{
myFakedObject = A.Fake<MyFakedClass>();
sut = new