微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!
autofixture专题提供autofixture的最新资讯内容,帮你更好的了解autofixture。
我目前正在使用xUnit,Moq和AutoFixture为我的Domain项目编写单元测试.我们来看看这个测试方法: [Theory] public void SameValueAs_OnOtherHasDifferentEmail_ReturnsFalse() { Fixture fix = new Fixture(); var sut = fix.CreateAnonymous
我在这个例子中使用AutoFixture来实现包含Mongo ObjectId的对象,就像这样 Fixture fixture = new Fixture(); fixture.Register(ObjectId.GenerateNewId); 但我每次测试都会这样做.是否有可能以某种方式为所有测试注册这个全球? 全局(或静态)无法做到这一点. 我通常做的是创建一个TestConventions类
我正在使用最新版本的Autofixture,我想阻止它自动填充子集合. 例如,我有一个具有List属性的Person类.我想要填写所有属性,列表除外. 我尝试使用此自定义: public class RemoveMultiples : ICustomization { public void Customize(IFixture fixture) { fixture
我希望能够使用AutoFixture.SemanticComparison比较以下两个对象的相似性: public class Object1 { public int a; } public class Object2 { public int a; public int b; } 现在,当我这样做的时候: var o1 = new Object1 { a = 1 }; var o
使用IFixture.Create< int>()生成的整数是唯一的吗? The Wiki says这些数字是随机的,但它也告诉我们这一点 The first numbers are generated within the range of [1, 255], as this is a set of values that are valid for all numeric data types
我正在使用AutoFixture,Moq和XUnit扩展([Theory]属性),如本博文 http://blog.ploeh.dk/2010/10/08/AutoDataTheorieswithAutoFixture中所述. 我注意到大多数单元测试看起来像这样: [Theory, AutoMoqData] public void Test( [Frozen] Mock<IServiceO
我有一个使用Open Generics的对象模型(是的,是的,现在我有两个问题;这就是为什么我在这里:): – public interface IOGF<T> { } class C { } class D { readonly IOGF<C> _ogf; public D( IOGF<C> ogf ) { _ogf = ogf; } } 我
我正在使用AutoFixture自定义来测试访问SQL Compact DB的存储库. 测试完成后立即删除此数据库对我非常有帮助.因为db是在自定义构造函数中创建的,所以我认为删除它的最佳位置是dispose方法. 我想的代码是: internal class ProjectRepositoryCustomization : ICustomization { private readonl
我们有一个枚举: enum Letters { A, B, C, D, E } 当我尝试: var frozenLetter = fixture.Freeze(Letters.D); 奇怪的是,frozenLetter == A. var letter = fixture.Create<Letters>(); var anotherLette
是否跨多个测试方法共享Fixture实例是一个好习惯? 或者为每种测试方法创建一个新的Fixture实例更好吗? 什么是最佳做法?如果你能为我提供一个反模式的来源,那将是一件好事. AutoFixture的名称来自 Fixture模式: “a test fixture is all the things we need to have in place in order to run a test
我使用NSubstitute很多.我爱它 我只是看AutoFixture.看起来很棒! 我已经看到了AutoFixture for NSubstitute,并在Moq中看到了一些关于如何使用这个功能的例子. 但我似乎无法将其翻译成NSubstitute. 我试过这个: var fixture = new Fixture().Customize(new AutoNSubstituteCustomiz
我有以下类型: public enum Status { Online, Offline } public class User { private readonly Status _status; public User(Status status) { _status = status; } public Status Status {get {ret
我开始使用AutoFixture http://autofixture.codeplex.com/,因为我的单元测试被大量的数据设置blo肿.我花更多的时间来设置数据,而不是写我的单元测试.以下是我的初始单元测试的样例(来自DDD蓝皮书的货物应用样本示例) [Test] public void should_create_instance_with_correct_ctor_parameters(
现在解决方案已经找到了短的外卖: AutoFixture返回冻结模拟就好了;我自己也是通过AutoFixture生成的,它的公共属性具有局部默认值,对于测试非常重要,AutoFixture设置为一个新的值.除了马克的答案之外,还有很多东西要学习. 原来的问题: 我昨天开始尝试AutoFixture,我的xUnit.net测试有Moq全部.我希望替换一些Moq的东西,或者使它更容易阅读,而且我特别感
我可以得到像这样的构造函数参数类型: Type type = paramInfo.ParameterType; 现在我想从这种类型创建存根对象.有可能吗?我试过autofixture: public TObject Stub<TObject>() { Fixture fixture = new Fixture(); return fixture.Create<TObject>()