Not Able to call The method Asynchronously in the Unit Test.

Posted by user43838 on Stack Overflow See other posts from Stack Overflow or by user43838
Published on 2010-03-16T15:19:48Z Indexed on 2010/03/16 16:41 UTC
Read the original article Hit count: 190

Filed under:
|
|

Hi everyone,

I am trying to call a method that passes an object called parameters.

    public void LoadingDataLockFunctionalityTest()
    {
        DataCache_Accessor target = DataCacheTest.getNewDataCacheInstance();

        target.itemsLoading.Add("WebFx.Caching.TestDataRetrieverFactorytestsync", true);

        DataParameters parameters = new DataParameters("WebFx.Core",
            "WebFx.Caching.TestDataRetrieverFactory",
            "testsync");



        parameters.CachingStrategy = CachingStrategy.TimerDontWait;
        parameters.CacheDuration = 0;
        string data = (string)target.performGetForTimerDontWaitStrategy(parameters);
        TestSyncDataRetriever.SimulateLoadingForFiveSeconds = true;
        Thread t1 = new Thread(delegate()
        {
            string s = (string)target.performGetForTimerDontWaitStrategy(parameters);
            Console.WriteLine(s ?? String.Empty);
        });
        t1.Start();
        t1.Join();


        Thread.Sleep(1000);

        ReaderWriterLockSlim rw = DataCache_Accessor.GetLoadingLock(parameters);


        Assert.IsTrue(rw.IsWriteLockHeld);
        Assert.IsNotNull(data);
    }

My test is failing all the time and i am not able step through the method..

Can someone please put me in the right direction

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about unit-testing