﻿
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using OpenLearningPlayer.Shared.API;
using OpenLearningPlayer.Shared.Auxiliary.Localization;
using OpenLearningPlayer.Shared.Domain;
using OpenLearningPlayer.Shared.Services;
using OpenLearningPlayer.Shared.ViewModels;
using MvvmCross.Plugins.Messenger;
using MvvmCross.Platform.IoC;
using MvvmCross.Platform;
using OpenLearningPlayer.Shared.DB;
using System.Linq;
using System.Windows;


namespace OpenLearningPlayer.Shared.Tests.ViewModels
{

    [TestClass]
    public class WordsTranslation_ViewModel_test : DB
    {

        /*
        public void MergeWordsTest()
        {

            XamlResourcesReader rr = new XamlResourcesReader("ViewModels\\WordsTranslation_ViewModel_test_data.xaml");

            WordsTranslation_ViewModel vm = new WordsTranslation_ViewModel(
                Mock.Of<INavigationService>(),
                Mock.Of<IDialogService>(),
                new AppSetting(),
                Mock.Of<IAudioAPI>(),
                Mock.Of<IFolderService>(),
                Mock.Of<IMvxMessenger>(),
                Mock.Of<ILocalization>());
            

            string db_name = "WordsTranslation_ViewModel_test_MergeWordsTest.db"; 

            EFDbContext db;
            db = RecreateDB(db_name);

            Dictionary dic1 = rr.Get<Dictionary>("dic1");
            db.AddNewItemToDBContext(dic1);

            LearningItem li1 = rr.Get<LearningItem>("li1");
            db.AddNewItemToDBContext(li1);

            db.SaveChanges();
            db.Close();

            db = ConnectToDb(db_name);
            dic1 = db.First<Dictionary>();

            vm.CurrentWord = dic1.Words[2];
            vm.CommandDispatcher.Execute("MergeWords");

            Assert.IsTrue(dic1.Words.Count == 2);
            Assert.IsTrue(dic1.Words[0].Forms == "[i'm]");
            Assert.IsTrue(li1.SubtitleCollection[0].Items[2].id == dic1.Words[0].id);
            //Assert.IsTrue();

        }
        */

        public WordsTranslation_ViewModel_test()
        {
            MvxSimpleIoCContainer.Initialize();
            Mvx.RegisterSingleton(Mock.Of<ILocalization>());
        }
    }
}
