using DataBase.Entities.Models;
using Microsoft.Extensions.Logging;
using Moq;
using Moq.EntityFrameworkCore;
using System.Reflection.Emit;
using User.Insight.Tracker.DataContracts;
using User.Insight.Tracker.DataProviders;

namespace Insight.Tracker.UnitTest
{

    public class UserInsightTrackerProviderTests
    {
        private readonly Mock<ILogger<UserInsightTrackerProvider>> _loggerMock;
        private IUserInsightTrackerProvider _providerMock;
        private Mock<ComputraceqaContext> _dbContext;
        public UserInsightTrackerProviderTests()
        {
            _loggerMock = new Mock<ILogger<UserInsightTrackerProvider>>();
            SetUpMockDbContext();
            _providerMock = new UserInsightTrackerProvider(_loggerMock.Object, _dbContext.Object);
        }
        private void SetUpMockDbContext()
        {
            _dbContext = new Mock<ComputraceqaContext>();
        }
        [Fact]
        public void GetEmployeeCallDetails()
        {
            SearchRequest<CallDetailFilterRequest> searchRequest = new SearchRequest<CallDetailFilterRequest>()
            {
                Filter = new CallDetailFilterRequest()
                {
                    CallEndedOn = null,
                    CallStartedOn = null
                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
                SortColumn  = "CallStartedOn",
                SortOrder = "desc"
            };
            _dbContext.Setup(x => x.CallDetails).ReturnsDbSet(new List<CallDetail>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }
        [Fact]
        public void GetSystemSleepDetails()
        {
            SearchRequest<SystemSleepRequest> searchRequest = new SearchRequest<SystemSleepRequest>()
            {
                Filter = new SystemSleepRequest()
                {
                    Description = "",
                    TriggeredOn = DateTime.Now,
                    TriggeredOff = DateTime.Now
                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
                SortColumn = "TriggeredOn",
                SortOrder = "desc"
            };
            _dbContext.Setup(x => x.SystemSleepDetails).ReturnsDbSet(new List<SystemSleepDetail>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }
        [Fact]
        public void GetEmployeeWorkingTime()
        {
            SearchRequest<EmployeeWorkingTimeRequest> searchRequest = new SearchRequest<EmployeeWorkingTimeRequest>()
            {
                Filter = new EmployeeWorkingTimeRequest()
                {
                    WorkLoggedOn = null,
                    WorkEndedOn = null
                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
                SortColumn = "WorkLoggedOn",
                SortOrder = "desc"
            };
            _dbContext.Setup(x => x.EmployeeWorkingTimes).ReturnsDbSet(new List<EmployeeWorkingTime>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }
        [Fact]
        public void GetSystemLoginDetails()
        {
            SearchRequest<SystemLoginDetailsRequest> searchRequest = new SearchRequest<SystemLoginDetailsRequest>()
            {
                Filter = new SystemLoginDetailsRequest()
                {
                    LoginTime = null,
                    LogoutTime = null
                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
                SortColumn = "LoginTime",
                SortOrder = "desc"
            };
            _dbContext.Setup(x => x.SystemLoginDetails).ReturnsDbSet(new List<SystemLoginDetail>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }

        [Fact]
        public void GetRunningApplications()
        {
            SearchRequest<RunningApplicationRequest> searchRequest = new SearchRequest<RunningApplicationRequest>()
            {
                Filter = new RunningApplicationRequest()
                {
                    StartedOn = null,
                    EndedOn = null
                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
                SortColumn = "StartedOn",
                SortOrder = "desc"
            };
            _dbContext.Setup(x => x.RunningApplicationDetails).ReturnsDbSet(new List<RunningApplicationDetail>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }

        [Fact]
        public void GetGraphicData()
        {
            SearchRequest<GraphDetailsRequest> searchRequest = new SearchRequest<GraphDetailsRequest>()
            {
                Filter = new GraphDetailsRequest()
                {
                    RequestTime = DateTime.Now,
                    IsLiveData = true
                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
            };
            _dbContext.Setup(x => x.GraphDetail).ReturnsDbSet(new List<GraphDetail>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }

        [Fact]
        public void GetDashboardData()
        {
            SearchRequest<DashboardDetailsRequest> searchRequest = new SearchRequest<DashboardDetailsRequest>()
            {
                Filter = new DashboardDetailsRequest()
                {                   
                    RequestStartDate = DateTime.Now,
                    RequestEndDate = DateTime.Now
                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
            };
            _dbContext.Setup(x => x.DashboardDetails).ReturnsDbSet(new List<DashboardDetails>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }

        [Fact]
        public void GetUserProfileData()
        {
            SearchRequest<UserProfileRequest> searchRequest = new SearchRequest<UserProfileRequest>()
            {
                Filter = new UserProfileRequest()
                {
                    RequestDateStart = DateTime.Now,
                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
            };
            _dbContext.Setup(x => x.UserProfile).ReturnsDbSet(new List<UserProfile>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }

        [Fact]
        public void GetAllActivity()
        {
            _dbContext.Setup(x => x.ActivityDetails).ReturnsDbSet(new List<ActivityDetails>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }

        [Fact]
        public void GetUserActivityDetails()
        {
            SearchRequest<UserActivityDetailsRequest> searchRequest = new SearchRequest<UserActivityDetailsRequest>()
            {
                Filter = new UserActivityDetailsRequest()
                {
                    Activity = "Sleep",
                    LoginTime = null,
                    LogoutTime = null

                },
                IgnorePaging = false,
                PageNumber = 1,
                PageSize = 10,
                SearchText = "",
            };
            _dbContext.Setup(x => x.UserActivityDetails).ReturnsDbSet(new List<UserActivityDetails>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);
        }

        [Fact]
        public void GetApplicationActivityReport()
        {
            ApplicationActivityReportRequest searchRequest = new ApplicationActivityReportRequest();
            {
                searchRequest = new ApplicationActivityReportRequest()
                {
                    EmpCode = "12345",
                    ChartType = "Sleep",
                    StartDate = null,
                    EndDate = null,
                    Device = "Windows",
                    Show = "Filter",
                    Type = "PieChart"
                };
            };
            _dbContext.Setup(x => x.ApplicationActivityReportResult).ReturnsDbSet(new List<ApplicationActivityReportResult>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);


        }


        [Fact]
        public void GetCallsActivityReport()
        {
            CallsActivityReportRequest searchRequest = new CallsActivityReportRequest();
            {
                searchRequest = new CallsActivityReportRequest()
                {
                    EmpCode = "12345",
                    ChartType = "Sleep",
                    StartDate = null,
                    EndDate = null,
                    Device = "Windows",
                    Show = "Filter",
                    Type = "PieChart"
                };
            };
            _dbContext.Setup(x => x.CallsActivityReportResult).ReturnsDbSet(new List<CallsActivityReportResult>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);


        }


        [Fact]
        public void GetSessionsActivityReport()
        {
            SessionActivityReportRequest searchRequest = new SessionActivityReportRequest();
            {
                searchRequest = new SessionActivityReportRequest()
                {
                    EmpCode = "12345",
                    StartedOn = DateTime.Now,
                    Device = "Windows",
                    EndedOn = DateTime.Now,
                    ChartType = "Sleep"

                };
            };
            _dbContext.Setup(x => x.SessionActivityReportResult).ReturnsDbSet(new List<SessionActivityReportResult>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);


        }

        [Fact]
        public void GetLogInActivityReport()
        {
            LogInActivityReportRequest searchRequest = new LogInActivityReportRequest();
            {
                searchRequest = new LogInActivityReportRequest()
                {
                    EmpCode= "12345",
                    StartedOn = DateTime.Now,
                    EndedOn = DateTime.Now,
                    ChartType = "Active"
                };
            };
            _dbContext.Setup(x => x.LogInActivityReportResult).ReturnsDbSet(new List<LogInActivityReportResult>() { });
            var response = 1;
            var result = response >= 0;
            Assert.True(result);


        }
}
    }

