Questions tagged [nbuilder]

Through a fluent, extensible interface, NBuilder allows you to rapidly create test data.

Through a fluent, extensible interface, NBuilder allows you to rapidly create test data, automatically assigning values to properties and public fields that are one of the built in .NET data types (e.g. ints and strings). NBuilder allows you to override for properties you are interested in using lambda expressions.

Resources

Installation

NBuilder can most easily be installed through its NuGet package.

Install-Package NBuilder
30 questions
1
vote
2 answers

NBuilder - Issue Creating Nested Object

I'm trying to create some dummy objects which have a hierachy like this: Post | ----User Pretty simple. Here's the code: var user = Builder.CreateNew().Build(); var posts = Builder.CreateListOfSize(100) .All() …
RPM1984
  • 72,246
  • 58
  • 225
  • 350
1
vote
1 answer

Defining extension method for fluent use

I am trying to add an extension method that generates a random HashSet of ints for use with NBuilder mocking library. This is the method I would like to shorten into a simple extension method: using System; using FizzWare.NBuilder; using…
Guerrilla
  • 13,375
  • 31
  • 109
  • 210
1
vote
1 answer

How does this .NET code work?

this code is part of NBuilder. I'm having a bad day .. and to prove it, I don't understand what this (simple) code is trying to do. Here are the answers, with the code after it. GetRandom.Phrase(5) == null or et or ut or do or elit or amet.. …
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
1
vote
1 answer

NBuilder Usage On Collection

I found this implementation of NBuilder here: https://gist.github.com/markgibaud/4150878 This works like a charm until I need to add some collection inside. For example: public class UserDto { public string UserName {get;set;} public…
ShP
  • 1,143
  • 1
  • 12
  • 41
1
vote
1 answer

NBuilder - How to create a collection that contains several derived class

I have entities: BaseEntity (Base Class & Abstract) DerivedOne (based on BaseEntity) DerivedTwo (based on BaseEntity) ... Is it possible to build a list (collection) of BaseEntity but contains instance of the derived classes only? Thanks EDIT I…
bonjorno
  • 201
  • 2
  • 12
1
vote
0 answers

Extension method casting the first parameter to a sub-type. Is this good?

I had another question here in the same context. Now I have another query. In NBuilder, FizzWare.NBuilder namespace contains the interface ISingleObjectBuilder and class SingleObjectBuilderExtension which is container of extension methods of…
Mohayemin
  • 3,841
  • 4
  • 25
  • 54
0
votes
2 answers

MVC3: delete an object in an database from an array of selected objects

I've successfully selected the Objects I want to delete. But the problem is when I remove an item from Object array, it doesn't make any changes. My code is following below.. My database public List db = new…
kk-dev11
  • 2,654
  • 5
  • 37
  • 48
0
votes
1 answer

NBuilder and DbContext invalid cast issue

I am really new to NBuilder, but it looks awesome so I thought I would have a go. I have a DatabaseContext which just inherits from DbContext like this: public class DatabaseContext : DbContext Now, I have created a service that queries the…
r3plica
  • 13,017
  • 23
  • 128
  • 290
0
votes
1 answer

NBuilder populate nested hashset

I am trying to populate some test data with NBuilder (https://github.com/nbuilder/nbuilder). Here is my class: public class Person { public string Name { get; set; } public HashSet AssociatedIds { get; set; } } I want to generate a…
Guerrilla
  • 13,375
  • 31
  • 109
  • 210
0
votes
3 answers

How to return derived class with C# generics

I am trying to generate some test data using NBuilder for automation for all the classes that extends a base class wherein each class will have different fields. Here is my code: public interface Interface { T method() where T :…
raj
  • 71
  • 7
0
votes
1 answer

Xamarin.ios - Using NBuilder to build mocks throws TypeCreationException

I'm using the NBuilder library to build mock http responses, everything works fine in Android, but in iOS each time that I want to build a model class this exception is fired. "FizzWare.NBuilder.TypeCreationException" and It says that my X model…
4gus71n
  • 3,717
  • 3
  • 39
  • 66
0
votes
1 answer

How do I write the continuation passing style for this Func call?

given: open System open System.Linq.Expressions open Microsoft.FSharp.Quotations open Microsoft.FSharp.Linq.RuntimeHelpers open FizzWare.NBuilder let toLinq (expr: Expr<'a -> 'b>) = let linq = LeafExpressionConverter.QuotationToExpression…
Maslow
  • 18,464
  • 20
  • 106
  • 193
0
votes
1 answer

NBuilder - creating more Random types e.g. EmailAddress

Right now I am using NBuilder to generate Customers in my mock repository. Unfortunately the only option I have for random strings seems to be .Phrase() var customers = Builder.CreateListOfSize(10) .All() …
VictorySaber
  • 3,084
  • 1
  • 27
  • 45
0
votes
2 answers

Getting NBuilder to build a List of Lists

I'm getting a parameter count mismatch with NBuilder, basically trying to Build up a List of Lists, can't seem to find any examples using NBuilder to do this: public class MyClass { public IEnumerable> Matrix { get; set;…
Mark W
  • 3,879
  • 2
  • 37
  • 53
0
votes
1 answer

Using NBuilder to test NHibernate mappings

I have been using NBuilder for a while in unit tests to simulate in-memory data and it's awesome, then I wanted to use it to test my NHibernate mappings, I thought it was going to be transparent but I can not figure out what I am doing wrong =( it…
Jupaol
  • 21,107
  • 8
  • 68
  • 100
1
2