using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using ResourcesManager.Interfaces;
using ResourcesManager.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ResourcesManagerTests.RepositoryTests
{
    [TestClass]
    class UserRepositoryTests
    {
        List<ApplicationUser> expectedUsers;
        Mock<IUserRepository> mockUserRepo;

        [TestInitialize]
        public void InitializeTestData()
        {
            expectedUsers = new List<ApplicationUser> {
                new ApplicationUser() { },
                new ApplicationUser() { },
                new ApplicationUser() { },
            };
            mockUserRepo = new Mock<IUserRepository>() { CallBase = true };

            mockUserRepo.Setup(m => m.GetUsers()).Returns(expectedUsers);

            //mockUserRepo.Setup(m => m.GetUserByID(It.IsAny<string>())).Returns((string id) =>
            //{
            //    return expectedUsers.FirstOrDefault(x => x.Id == id);
            //});

            //mockUserRepo.Setup(m => m.(It.IsAny<Resource>())).Returns((Resource resource) =>
            //{
            //    expectedUsers.Add(resource);
            //    return true;
            //});

            //mockUserRepo.Setup(m => m.UpdateResouce(It.IsAny<Resource>())).Returns((Resource target) =>
            //{
            //    var resource = expectedUsers.FirstOrDefault(x => x.Id == target.Id);
            //    if (resource == null)
            //    {
            //        return false;
            //    }
            //    resource.Name = target.Name;
            //    resource.Description = target.Description;
            //    resource.AssetTag = target.AssetTag;
            //    resource.ImagePath = target.ImagePath;
            //    resource.IsShared = target.IsShared;
            //    resource.TimeLimit = target.TimeLimit;
            //    resource.Reservation = target.Reservation;
            //    resource.Users = target.Users;
            //    return true;
            //});

            //mockUserRepo.Setup(m => m.DeleteResouce(It.IsAny<int>())).Returns((int id) =>
            //{
            //    var resource = expectedUsers.FirstOrDefault(x => x.Id == id);
            //    if (resource == null)
            //    {
            //        return false;
            //    }
            //    expectedUsers.Remove(resource);
            //    return true;
            //});
        }

        [TestCleanup]
        public void Resources_CleanUpTestData()
        {
            expectedUsers = null;
            mockUserRepo = null;
        }
    }
}
