Click here to Skip to main content
15,900,725 members
Home / Discussions / C#
   

C#

 
Questionhow do I get datasource to put to any drive c# Pin
Member 97020587-May-15 14:19
Member 97020587-May-15 14:19 
AnswerRe: how do I get datasource to put to any drive c# Pin
Dave Kreskowiak7-May-15 16:50
mveDave Kreskowiak7-May-15 16:50 
AnswerRe: how do I get datasource to put to any drive c# Pin
OriginalGriff7-May-15 20:35
mveOriginalGriff7-May-15 20:35 
AnswerRe: how do I get datasource to put to any drive c# Pin
Richard Deeming8-May-15 0:35
mveRichard Deeming8-May-15 0:35 
QuestionHow to run a setup file in different sysytem.. Pin
Jayamanickam7-May-15 2:32
Jayamanickam7-May-15 2:32 
AnswerRe: How to run a setup file in different sysytem.. Pin
OriginalGriff7-May-15 3:10
mveOriginalGriff7-May-15 3:10 
GeneralRe: How to run a setup file in different sysytem.. Pin
Brisingr Aerowing7-May-15 4:21
professionalBrisingr Aerowing7-May-15 4:21 
GeneralRe: How to run a setup file in different sysytem.. Pin
ZurdoDev7-May-15 6:00
professionalZurdoDev7-May-15 6:00 
QuestionRe: How to run a setup file in different sysytem.. Pin
ZurdoDev7-May-15 4:06
professionalZurdoDev7-May-15 4:06 
QuestionC# web browser Pin
Jonteepersson967-May-15 1:56
Jonteepersson967-May-15 1:56 
GeneralRe: C# web browser Pin
Sascha Lefèvre7-May-15 2:04
professionalSascha Lefèvre7-May-15 2:04 
GeneralRe: C# web browser Pin
Jonteepersson967-May-15 2:13
Jonteepersson967-May-15 2:13 
GeneralRe: C# web browser Pin
Sascha Lefèvre7-May-15 2:20
professionalSascha Lefèvre7-May-15 2:20 
AnswerRe: C# web browser Pin
Ravi Bhavnani7-May-15 2:57
professionalRavi Bhavnani7-May-15 2:57 
QuestionHelp Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Thomas Maierhofer (Tom)7-May-15 0:25
Thomas Maierhofer (Tom)7-May-15 0:25 
AnswerRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Eddy Vluggen7-May-15 1:14
professionalEddy Vluggen7-May-15 1:14 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Thomas Maierhofer (Tom)7-May-15 1:52
Thomas Maierhofer (Tom)7-May-15 1:52 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Eddy Vluggen7-May-15 2:28
professionalEddy Vluggen7-May-15 2:28 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Thomas Maierhofer (Tom)7-May-15 3:03
Thomas Maierhofer (Tom)7-May-15 3:03 
The long method names are extracted by BDDfy to generate the test documentation:
http://docs.teststack.net/bddfy/

Behavior Driven Tests have all the same structure:
Given(...)
When( ... )
Then( ... )

Our old approach of concurrency testing does not fit in very well:

Test.Run(...)
Assert( Test.Is...)

You can't split this up semantically in Given/When/Then

The new approach is better:
Given ...
When ...
And I start write operation #1

is just a fluent Add() of this method:
.And(c => c.i_start_write_operation(1))
C#
void i_start_write_operation(int number)
{
    concurrencyTester.Start(
                     c =>
                     {
                         readerWriterLock.EnterWriteLock();
                         using (concurrencyTester.Marks["Write"].BeginSection())
                         {
                             concurrencyTester.Events[WriteOperationPending, number].Wait();
                         }
                         readerWriterLock.ExitWriteLock();
                     }, "Write Operation #{0}", number);
}

The execution of this test is controlled outside with the events:
C#
void release_write_operations(int[] numbers)
{

    foreach (var number in numbers)
    {
        concurrencyTester.Events[WriteOperationPending, number].Set();
    }

}

This is the point in the test where the operations are released:
C#
.When(c => c.release_read_operations(new[] { 1, 2 }))
.And(c => c.release_write_operations(new[] { 1, 2 }))

After that we can check what happens. The sections in the Marks collection are recorded and the relations Before, Intersect and After are queryable. So it is simple to express that the Read Sections should not intersect with the write sections.

This is the Timeline Dump of this test (EP means execution path):
Timeline Dump:
EP[0] Read-Enter
EP[2] Read-Enter
EP[2] Read-Leave
EP[0] Read-Leave
EP[1] Write-Enter
EP[1] Write-Leave
EP[3] Write-Enter
EP[3] Write-Leave

The first read on EP0 intersects with the second read on EP2, this is ok because multiple readers are allowed.

The first Write on EP1 is delayed until all reads are complete
The second Write on EP3 is delayed until the first read completes, this is OK, because only one writer is allowed.

Without the concurrency tester this is much harder to test.

GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Eddy Vluggen7-May-15 5:27
professionalEddy Vluggen7-May-15 5:27 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Thomas Maierhofer (Tom)7-May-15 9:11
Thomas Maierhofer (Tom)7-May-15 9:11 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Eddy Vluggen8-May-15 1:48
professionalEddy Vluggen8-May-15 1:48 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Thomas Maierhofer (Tom)8-May-15 11:09
Thomas Maierhofer (Tom)8-May-15 11:09 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Eddy Vluggen9-May-15 4:55
professionalEddy Vluggen9-May-15 4:55 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Thomas Maierhofer (Tom)9-May-15 6:29
Thomas Maierhofer (Tom)9-May-15 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.