locked
How to call LyncClient.GetClient() in other class RRS feed

  • Question

  • Hi,

    Could you please guide me how to use LyncClient.GetClient() once again in other [testmethod]? I'm using Unit test in vs2010 to test Lync 2013.

    I used static LyncClient _LyncClient ; in the top o class then using again for 2 classes below, the second one always get Invalid state, is there any way to reset state of Lync?

     [TestClass]

     public class UnitTest1
        {
            
            static LyncClient _LyncClient;

         [TestMethod]

         public void TestMethod1()
            {

              ....

              _LyncClient = LyncClient.GetClient();

              ....

            }

    [TestMethod]

         public void TestMethod2()
            {

              ....

              _LyncClient = LyncClient.GetClient();

              ....

            }

        ......

      }



    • Edited by KyNguyen Friday, July 12, 2013 8:43 AM
    Monday, July 8, 2013 7:26 AM

Answers

  • LyncClient is a singleton object and is obtained from the running Lync client process. No matter how many times you call the static GetClient method from any other running process, the Lync client process always returns the same object. That being said, you should not get an invalid LyncClient object in subsequent calls.


    John Austin Senior Programming Writer Microsoft

    • Proposed as answer by John M. Austin Friday, July 12, 2013 5:34 PM
    • Marked as answer by Allen[S] Thursday, December 5, 2013 2:20 PM
    Friday, July 12, 2013 5:34 PM

All replies

  • LyncClient is a singleton object and is obtained from the running Lync client process. No matter how many times you call the static GetClient method from any other running process, the Lync client process always returns the same object. That being said, you should not get an invalid LyncClient object in subsequent calls.


    John Austin Senior Programming Writer Microsoft

    • Proposed as answer by John M. Austin Friday, July 12, 2013 5:34 PM
    • Marked as answer by Allen[S] Thursday, December 5, 2013 2:20 PM
    Friday, July 12, 2013 5:34 PM
  • Thank John.

    My situation is:

    - Lync Client is logged in

    - Use the _LyncClient = LyncClient.GetClient(); in the frist Test Method, it returns SignedIn state (it's correct)

    - Use the _LyncClient = LyncClient.GetClient(); or  the static _LyncClient again in the second Test Method, it returns Invalid state.

    Could you please guide me how to get SignedIn state of Lync client in other Test Method?

    Best!

    Monday, July 22, 2013 4:38 AM
  • It's not clear yet: do you ever sign out of Lync client or exit the process? If so, then you will need to follow this workaround:  http://social.msdn.microsoft.com/Forums/lync/en-US/09639fc5-f933-4744-a8b6-86ef9567362a/selfcontact-is-null-after-restarting-lync-client

    -- How To Ask a Question: http://support.microsoft.com/kb/555375 -- This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

    Monday, July 29, 2013 6:53 PM
  • No, I don't signout or exit the process, more information that I use non-UI suppresion. I use Unit Test of VS2010.

    It's weird because the Lync still be signed in but using the method getClient() in other [Test Method] always returns invalid state.

    Have you ever tried? please help me.



    <input id="ext_msg_elm" type="hidden" />
    • Edited by KyNguyen Tuesday, August 6, 2013 6:25 AM correct spelling
    Friday, August 2, 2013 9:49 AM
  • Hi,

    To continue my points above, and as I know the LyncClient.GetClient() method should always be called in the same thread due the limit imposed by COM.

    So in my case because I need to run this method in different [Test Mehtod] of Unit Test that may use different thread/test run, then the invalid state should be returned. Am I missing something? please correct and advise if any solution for using Unit test to write Lync test cases.

    Thanks,

    Ky


    <input id="ext_msg_elm" type="hidden" />

    Wednesday, August 7, 2013 9:29 AM