using EQNetwork.Services;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using EQNetwork;
using EQNetwork.Objects;
using EQNetwork.Controllers;
using EQNetwork.Utility;
using System.Collections.Generic;

namespace UnitTests
{


    /// <summary>
    ///This is a test class for Upload_ControllerTest and is intended
    ///to contain all Upload_ControllerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class User_TwitterFindFriends_ControllerTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes

        static EQProcess _eq = null;
        static string _message = null;

        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
            _eq = new EQProcess("accesskey", "secret");

            _eq.SessionService.Create("BrianARice", "f00tball",
                (Session session, EQException ex) => // onComplete
                {
                    if (ex != null)
                        Assert.Fail(ex.Message);
                }
            );

            while (_eq.Session == null) System.Threading.Thread.Sleep(100);
        }

        [ClassCleanup()]
        public static void MyClassCleanup()
        {
        }

        [TestInitialize()]
        public void MyTestInitialize()
        {
            _message = null;
        }

        [TestCleanup()]
        public void MyTestCleanup()
        {
            while (_message == null)
                System.Threading.Thread.Sleep(100);
            Console.WriteLine(_message); Assert.AreEqual("success", _message);
        }

        #endregion

        /// <summary>
        ///A test for User_TwitterFindFriends_Controller
        ///</summary>
        [TestMethod()]
        public void User_TwitterFindFriends_Controller_Test()
        {
            DateTime start = DateTime.Now;

            User_TwitterFindFriends_Controller controller = new User_TwitterFindFriends_Controller(_eq);

            // controller.Search = "sa";
            controller.SocialSearchType = Db.SocialSearchType.SearchAll;
            controller.PagingParameters = new PagingParameters(5, "Alpha");

            controller.Start((EQException ex) => // onComplete
            {
                if (ex == null)
                {
                    if (controller.HasMore == true)
                    {
                        controller.More((EQException ex2) => // onComplete
                        {
                            if (ex2 == null)
                                _message = "success";
                            else
                                _message = ex.Message;
                        });
                    }
                    else
                        _message = "HasMore is false";
                }
                else
                    _message = ex.Message;
            });
        }
    }
}
