shekharpro / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

Replace UsingEnums, UsingLiterals and other generators in MbUnit v3 #396

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Some people in the forum have indicated that they miss the Using* features 
from MbUnit v2.  We should provide replacements in MbUnit v3.

Original issue reported on code.google.com by jeff.br...@gmail.com on 27 Feb 2009 at 7:30

GoogleCodeExporter commented 8 years ago
Basically this amounts to implementing a few more data source attributes 
similar to
RowAttribute and FactoryAttribute that can generate sequences.

Specifically we need replacements for: UsingEnum, UsingImplementations, 
UsingLinear,
UsingLiterals.  We already have UsingFactories (as Factory).  We could probably
consider adding a few extra generators besides these old ones.

We don't necessarily need to keep the old syntax from MbUnit v2.  In fact, I'd
specifically like to avoid the word "Using".

Here's another alternative nomenclature:

// produce all values of MyEnum
[EnumData(typeof(MyEnum))] 

// produce 0, 2, 4, 6.
[SequenceData(From = 0, To = 6, Step = 2)]

// produce 3 randomized strings that match a pattern
[RandomStringData(3, Pattern = "[A-M][a-z]+")]

// produce 3 random numbers between 10 and 25
[RandomNumberData(3, Minimum = 10, Maximum = 25)]

// etc...

Original comment by jeff.br...@gmail.com on 28 Apr 2009 at 6:56

GoogleCodeExporter commented 8 years ago

Original comment by Yann.Tre...@gmail.com on 28 Apr 2009 at 7:52

GoogleCodeExporter commented 8 years ago
Implemented EnumData and SequenceData.

Considering the existing literal data sources (CsvData and XmlData in 
particular), 
is a replacement for UsingLiterals really needed?

Original comment by Yann.Tre...@gmail.com on 1 May 2009 at 7:30

GoogleCodeExporter commented 8 years ago
Implemented RandomData for numbers.

Extending RandomData for string would be very cool. But generating a random 
string 
from a regular expression seems to be pretty tricky...

Original comment by Yann.Tre...@gmail.com on 8 May 2009 at 5:51

GoogleCodeExporter commented 8 years ago
Indeed, it's pretty tricky to generate random strings from regular expressions,
moreover it might even be undesirable.  However, perhaps we could leverage some
existing data generator library of some kind.

MbUnit v2 provided TestFu which has some fancy data generation facilities.  I 
don't
think it makes sense to use the library as-is but there are things we could 
borrow
perhaps.

Another fruitful avenue for exploration might be integration with products like 
Red
Gate's data generator.

Original comment by jeff.br...@gmail.com on 8 May 2009 at 6:23

GoogleCodeExporter commented 8 years ago
Mmh... That' interesting. 

We could indeed create a little framework similar to TestFu (part of Gallio? 
Gallio.Utility? or as a new project of the solution?) which provides various 
data 
generators: 
- random numbers, strings, DateTimes, etc., 
- remarkable sequences such as prime numbers, fibonnacci, etc. 
- Contrainted random values such even/odd values, etc.
- Useful predefined values ("The lazy dog...", "Lorem ipsum...") 
- Random items from built-in dictionnaries (common US male names, country 
names, 
state names, System.Drawing.Color, etc.)

Then to add to MbUnit one or more column providers, or to extend RandomData and 
Sequence.Data.

[RandomData(5, DataSource = RandomDataSource.CountryNameEn)]
-> "Canada", "China", "Japan", "Russia", "South Africa"

[RandomData(3, DataSource = RandomDataSource.KnownColor)]
-> Color.Black, Color.Fushia, Color.DrakGreen

[SequenceData(0, 20, DataSource = SequenceDataSource.Prime)]
-> 2, 3, 5, 7, 11, 13, 17, 19

[SpecialData(SpecialDataSource.LoremIpsum)]
-> "Lorem ipsum dolor sit amet, ..."

etc.

Original comment by Yann.Tre...@gmail.com on 8 May 2009 at 7:04

GoogleCodeExporter commented 8 years ago
Everything is there (more or less)

Original comment by Yann.Tre...@gmail.com on 2 Jun 2009 at 1:33