Click here to Skip to main content
15,891,607 members
Home / Discussions / C#
   

C#

 
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 
Example: If you develop a Reader/Writer Lock component (I know this class exists already, but for the understanding), you can't test the component without threads. The synchronization mechanism is the essential behavior of this component.

The article you mentioned uses a Java framework with essentially the same approach what we have developed now. They name it "Executors" but this is not the point. We are far beyond that. For now we want a framework that can be used for BDD in a more elegant way.

These are fragments from the ConcurrencyTester we are developing now. In fact it is a BDD Test with BDDfy, NUnit and Shoudy testing the .NET ReaderWriterLock (as a sample):
C#
[Test]
public void MultipleReaders()
{

        using (concurrencyTester = new ConcurrencyTester())
        {
            this.Given(c => c.new_reader_writer_lock())
                .And(c => c.i_start_read_operation(1))
                .And(c => c.i_wait_till_read_operation_is_pending(1))
                .And(c => c.i_start_write_operation(1))
                .And(c => c.i_start_read_operation(2))
                .And(c => c.i_wait_till_read_operation_is_pending(2))
                .And(c => c.i_start_write_operation(2))
                .When(c => c.release_read_operations(new[] { 1, 2 }))
                .And(c => c.release_write_operations(new[] { 1, 2 }))
                .And(c => c.wait_for_test_end())
                .Then(c => c.write_operations_should_not_intersect_with_read_operations())
                .And(c => c.write_operations_should_not_intersect_with_other_write_operations())
                .BDDfy();

            concurrencyTester.Marks.DumpTimeline();
        }
}


In the user story scenario it uses steps like:
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);
}
To describe things on a different thread.
After the test run has ended (we are multi threaded) we check what should be and what not:
C#
void write_operations_should_not_intersect_with_read_operations()
{
    foreach (var intersect in this.concurrencyTester.Marks["Write"].Sections.SelectMany(readSection => readSection.Relations.Intersect))
    {
        intersect.Mark.Name.ShouldNotBe("Read");
    }
}

So it should become very easy to write concurrency tests with this framework. I'm now interested in test cases where concurrency / multi threaded tests are needed.

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 
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 
GeneralRe: Help Needed: Unit Tests with multiple Threads / Concurrency / Correct Locking Pin
Eddy Vluggen9-May-15 12:17
professionalEddy Vluggen9-May-15 12:17 
QuestionExecute Multiple Commands using Process.StandardInput Pin
Django_Untaken6-May-15 23:56
Django_Untaken6-May-15 23:56 
AnswerRe: Execute Multiple Commands using Process.StandardInput Pin
Sascha Lefèvre7-May-15 0:40
professionalSascha Lefèvre7-May-15 0:40 
GeneralRe: Execute Multiple Commands using Process.StandardInput Pin
Django_Untaken7-May-15 0:47
Django_Untaken7-May-15 0:47 
GeneralRe: Execute Multiple Commands using Process.StandardInput Pin
Sascha Lefèvre7-May-15 1:00
professionalSascha Lefèvre7-May-15 1:00 
GeneralRe: Execute Multiple Commands using Process.StandardInput Pin
Eddy Vluggen7-May-15 1:16
professionalEddy Vluggen7-May-15 1:16 
GeneralRe: Execute Multiple Commands using Process.StandardInput Pin
Django_Untaken7-May-15 1:58
Django_Untaken7-May-15 1:58 
GeneralRe: Execute Multiple Commands using Process.StandardInput Pin
Eddy Vluggen7-May-15 2:18
professionalEddy Vluggen7-May-15 2:18 
GeneralRe: Execute Multiple Commands using Process.StandardInput Pin
Django_Untaken8-May-15 0:00
Django_Untaken8-May-15 0:00 

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.