using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CARRE_DSS2.Models;
using System.Diagnostics;


namespace CARRE_DSS2.Tests
{
    [TestClass]
    public class RepositoryTest
    {
        [TestMethod]
        public void RiskElementsTest()
        {
            var rep = new CarreRiskRepository();

            var reList = rep.getRiskElements();

            int i = 1;

            foreach (RiskElement re in reList)
            {
                Debug.WriteLine(i.ToString());
                Debug.WriteLine(re.ToString());

                var obList = rep.getObservablesOfRiskElement(re.Node);

                foreach(String obNode in obList)
                    Debug.WriteLine(obNode);

                i++;
                Debug.Write("\n");
            }
        }

        [TestMethod]
        public void ObservablesTest()
        {
            var rep = new CarreRiskRepository();
            var obList = rep.getObservables();

            int i = 1;
            foreach (Observable ob in obList)
            {
                Debug.WriteLine(i.ToString());
                Debug.WriteLine(ob);
            }
        }

        [TestMethod]
        public void RestFulApiTest()
        {

            string token = "37a48860c70a298de7f340494dda8322c95ed16c";

            var cApi = new CarreRestFull();

            var p = cApi.validateToken(token);

            if (p == null)
            {
                Debug.WriteLine("Blad podczas pobierania danych z prawidlowego tokenu");
            }
            else
            {
                Debug.WriteLine(p.UserName + " " + p.GraphName + " " + p.Email);
            }

            p = cApi.validateToken("sdfsdfsdf");

            if (p == null)
            {
                Debug.WriteLine("Nie pobral danych z nieprawidlowego tokena");
            }
            else
            {
                Debug.WriteLine("To nie powinno się nigdy wyswietlic");
            }

            var listOfM = cApi.getMeasurmentsList(token);

            Debug.WriteLine(" ");
            foreach (var m in listOfM)
            {
                Debug.WriteLine(m.measurement + " " + m.firstMeasured.ToString() + " " + m.lastMeasured.ToString());
            }


        }
    }
}
