using DataBase.Entities.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Graph.SecurityNamespace;
using Moq;
using User.Insight.Tracker.Common;
using User.Insight.Tracker.DataContracts;
using User.Insight.Tracker.DataProviders;
using User.Insight.Tracker.Services;

namespace Insight.Tracker.UnitTest
{
    public class UserInsightTrackerServiceTests
    {
        private readonly Mock<ILogger<UserInsightTrackerService>> _loggerMock;
        private readonly Mock<IUserInsightTrackerProvider> _providerMock;
        private readonly Mock<IUtils> _IUtils;
        private IUserInsightTrackerService _userTrackerServiceMock;
        public UserInsightTrackerServiceTests()
        {
            _loggerMock = new Mock<ILogger<UserInsightTrackerService>>();
            _providerMock = new Mock<IUserInsightTrackerProvider>();
            _IUtils = new Mock<IUtils>();
            _userTrackerServiceMock = new UserInsightTrackerService(_loggerMock.Object, _providerMock.Object, _IUtils.Object);
        }

        private JwtTokenDetail GetJwtUser()
        {
            var userDetailsJwt = new JwtTokenDetail() { Email = "Email" };

            return userDetailsJwt;
        }

        [Fact]
        public void GetGetCallDetailsNew_Success()
        {
            try
            {
                SearchRequest<CallDetailFilterRequest> searchRequest = new SearchRequest<CallDetailFilterRequest>()
                {
                    Filter = new CallDetailFilterRequest()
                    {
                        CallEndedOn = null,
                        CallStartedOn = null
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                    SortColumn = "CallEndedOn",
                    SortOrder = "desc"

                };
                var dataSet = new List<CallDetail>()
                {
                    new CallDetail()
                    {
                        Id = 15021,
                        EmpCode = "15505",
                        CallWith = "Ashil Manish Gandhi (You)",
                        CallStartedOn = null,
                        CallEndedOn = null,
                        CreatedOn = null,
                        UpdatedOn =  null,
                        Total_Records = 0,
                        Total_Pages = 0
                    }
                };
                // Arrange
                var utilsMock = new Mock<IUtils>();
                utilsMock.Setup(u => u.GetMessage("UserInvalid")).Returns("User is invalid.");

                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock
                    .Setup(p => p.GetEmployeeCallDetails(It.IsAny<SearchRequest<CallDetailFilterRequest>>(), It.IsAny<JwtTokenDetail>()))
                    .Returns(dataSet); var response = _userTrackerServiceMock.GetCallDetails(searchRequest, GetJwtUser());
                var dataSet1 = new List<CallDetailsResponse>()
                {
                    new CallDetailsResponse()
                    {
                        Id = dataSet.First().Id,
                        EmpCode = dataSet.First().EmpCode,
                        CallWith = dataSet.First().CallWith,
                        CallStartedOn = dataSet.First().CallStartedOn,
                        CallEndedOn = dataSet.First().CallEndedOn,
                        CreatedOn = dataSet.First().CreatedOn,
                        UpdatedOn =  dataSet.First().UpdatedOn
                    }
                };

                PageResponse<CallDetailsResponse> obj = new PageResponse<CallDetailsResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }

        [Fact]
        public void GetRunningApplicationsDetailed_Success()
        {
            try
            {
                SearchRequest<ApplicationTabDetailsRequest> searchRequest = new SearchRequest<ApplicationTabDetailsRequest>()
                {
                    Filter = new ApplicationTabDetailsRequest()
                    {
                        EmpCode ="",
                        ApplicationName ="",
                        StartedOn =null,
                        EndedOn = null,
                        ResultsFor = null
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                    SortColumn = "CallEndedOn",
                    SortOrder = "desc"

                };
                var dataSet = new List<ApplicationTabDetailsView>()
                {
                    new ApplicationTabDetailsView()
                    {
                        emp_code = "15505",
                        EmployeeName = "Ashil Manish Gandhi (You)",
                        description = "",
                        Total_Browsing_time = 0,
                        application_name ="",
                        started_on = null,
                        EndedOn =null,
                        CreatedOn = null,
                        UpdatedOn =  null,
                        Total_Records = 0,
                        Total_Pages = 0
                    }
                };
                // Arrange
                var utilsMock = new Mock<IUtils>();
                utilsMock.Setup(u => u.GetMessage("UserInvalid")).Returns("User is invalid.");

                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock
                    .Setup(p => p.GetRunningApplicationsDetailed(It.IsAny<SearchRequest<ApplicationTabDetailsRequest>>(), It.IsAny<JwtTokenDetail>()))
                    .Returns(dataSet); var response = _userTrackerServiceMock.GetRunningApplicationsDetailed(searchRequest, GetJwtUser());
                var dataSet1 = new List<ApplicationTabDetailsResponse>()
                {
                    new ApplicationTabDetailsResponse()
                    {
                        emp_code = dataSet.First().emp_code,
                        description = dataSet.First().description,
                        ApplicationName = dataSet.First().application_name,
                        StartedOn = dataSet.First().started_on,
                        EndedOn = dataSet.First().EndedOn,
                        TotalBrowsingTime = dataSet.First().Total_Browsing_time,
                        CreatedOn = dataSet.First().CreatedOn,
                        UpdatedOn =  dataSet.First().UpdatedOn,
                        EmployeeName=dataSet.First().EmployeeName
                    }
                };

                PageResponse<ApplicationTabDetailsResponse> obj = new PageResponse<ApplicationTabDetailsResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }

        [Fact]
        public void GetSystemSleepDetailsNew_Success()
        {
            try
            {
                SearchRequest<SystemSleepRequest> searchRequest = new SearchRequest<SystemSleepRequest>()
                {
                    Filter = new SystemSleepRequest()
                    {
                        Description = "",
                        TriggeredOn = null,
                        TriggeredOff = null
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                    SortColumn = "TriggeredOn",
                    SortOrder = "desc"
                };
                var dataSet = new List<SystemSleepDetail>()
                {
                    new SystemSleepDetail()
                    {
                        Id = 15021,
                        EmpCode = "15505",
                        Description ="",
                        TriggeredOn = DateTime.Now,
                        CreatedOn = DateTime.Now,
                        UpdatedOn = DateTime.Now,
                        Total_Records = 0,
                        Total_Pages = 0
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetSystemSleepDetails(It.IsAny<SearchRequest<SystemSleepRequest>>(), It.IsAny<JwtTokenDetail>())).Returns(dataSet);
                var response = _userTrackerServiceMock.GetSystemSleepDetails(searchRequest, GetJwtUser());
                var dataSet1 = new List<SystemSleepDetailResponse>()
                {
                    new SystemSleepDetailResponse()
                    {
                        Id = dataSet.First().Id,
                        EmpCode = dataSet.First().EmpCode,
                        Description = dataSet.First().Description,
                        TriggeredOn = dataSet.First().TriggeredOn,
                        CreatedOn = dataSet.First().CreatedOn,
                        UpdatedOn =  dataSet.First().UpdatedOn
                    }
                };
                PageResponse<SystemSleepDetailResponse> obj = new PageResponse<SystemSleepDetailResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };
                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }
        [Fact]
        public void GetSystemLoginDetailsNew_Success()
        {
            try
            {
                SearchRequest<SystemLoginDetailsRequest> searchRequest = new SearchRequest<SystemLoginDetailsRequest>()
                {
                    Filter = new SystemLoginDetailsRequest()
                    {
                        LoginTime = null,
                        LogoutTime = null
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                    SortColumn = "LoginTime",
                    SortOrder = "desc"
                };
                var dataSet = new List<SystemLoginDetail>()
                {
                    new SystemLoginDetail()
                    {
                        Id = 15021,
                        EmpCode = "15505",
                        LoginTime = DateTime.Now,
                        LogoutTime = DateTime.Now,
                        SystemStatus = "",
                        IpAddress = "",
                        ComputerName =  "",
                        AppVersion ="",
                        CreatedOn = DateTime.Now,
                        UpdatedOn = DateTime.Now,
                        Total_Records = 0,
                        Total_Pages = 0
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetSystemLoginDetails(It.IsAny<SearchRequest<SystemLoginDetailsRequest>>(), It.IsAny<JwtTokenDetail>())).Returns(dataSet);
                var response = _userTrackerServiceMock.GetSystemLoginDetails(searchRequest, GetJwtUser());
                var dataSet1 = new List<SystemLoginDetailsResponse>()
                {
                    new SystemLoginDetailsResponse()
                    {
                        Id = dataSet.First().Id,
                        EmpCode = dataSet.First().EmpCode,
                        LoginTime = dataSet.First().LoginTime,
                        LogoutTime = dataSet.First().LogoutTime,
                        SystemStatus = dataSet.First().SystemStatus,
                        IpAddress = dataSet.First().IpAddress,
                        ComputerName = dataSet.First().ComputerName,
                        AppVersion = dataSet.First().AppVersion,
                        CreatedOn = dataSet.First().CreatedOn,
                        UpdatedOn =  dataSet.First().UpdatedOn
                    }
                };
                PageResponse<SystemLoginDetailsResponse> obj = new PageResponse<SystemLoginDetailsResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }

        [Fact]
        public void GetEmployeeWorkingTimeNew_Success()
        {
            try
            {
                SearchRequest<EmployeeWorkingTimeRequest> searchRequest = new SearchRequest<EmployeeWorkingTimeRequest>()
                {
                    Filter = new EmployeeWorkingTimeRequest()
                    {
                        WorkLoggedOn = null,
                        WorkEndedOn = null,
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                    SortColumn = "WorkLoggedOn",
                    SortOrder = "desc"
                };
                var dataSet = new List<EmployeeWorkingTime>()
                {
                    new EmployeeWorkingTime()
                    {
                        Id = 15021,
                        EmpCode = "15505",
                        TotalActive = 0,
                        TotalIdle = 0,
                        TotalSleep = 0,
                        WorkLoggedOn = DateTime.Now,
                        CreatedOn = DateTime.Now,
                        UpdatedOn = DateTime.Now,
                        Total_Records = 0,
                        Total_Pages = 0
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetEmployeeWorkingTime(It.IsAny<SearchRequest<EmployeeWorkingTimeRequest>>(), It.IsAny<JwtTokenDetail>())).Returns(dataSet);
                var response = _userTrackerServiceMock.GetEmployeeWorkingTime(searchRequest, GetJwtUser());
                var dataSet1 = new List<EmployeeWorkingTimeResponse>()
                {
                    new EmployeeWorkingTimeResponse()
                    {
                        Id = dataSet.First().Id,
                        EmpCode = dataSet.First().EmpCode,
                        TotalActive = dataSet.First().TotalActive,
                        TotalIdle = dataSet.First().TotalIdle,
                        TotalSleep = dataSet.First().TotalSleep,
                        WorkLoggedOn = dataSet.First().WorkLoggedOn,
                        CreatedOn = dataSet.First().CreatedOn,
                        UpdatedOn =  dataSet.First().UpdatedOn
                    }
                };
                PageResponse<EmployeeWorkingTimeResponse> obj = new PageResponse<EmployeeWorkingTimeResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }

        [Fact]
        public async Task GetRunningApplicationsNew_Success()
        {
            try
            {
                SearchRequest<RunningApplicationRequest> searchRequest = new SearchRequest<RunningApplicationRequest>()
                {
                    Filter = new RunningApplicationRequest()
                    {
                        StartedOn = null,
                        EndedOn = null,
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                    SortColumn = "StartedOn",
                    SortOrder = "desc"
                };
                var dataSet = new List<RunningApplicationDetail>()
                {
                    new RunningApplicationDetail()
                    {
                        Id = 15021,
                        EmpCode = "15505",
                        ApplicationName = "",
                        StartedOn = DateTime.Now,
                        CreatedOn = DateTime.Now,
                        UpdatedOn = DateTime.Now,
                        Total_Records = 0,
                        Total_Pages = 0
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetRunningApplications(It.IsAny<SearchRequest<RunningApplicationRequest>>(), It.IsAny<JwtTokenDetail>())).Returns(Task.FromResult(dataSet));
                var response = await _userTrackerServiceMock.GetRunningApplications(searchRequest, GetJwtUser());
                var dataSet1 = new List<RunningApplicationResponse>()
                {
                    new RunningApplicationResponse()
                    {
                        Id = dataSet.First().Id,
                        EmpCode = dataSet.First().EmpCode,
                        ApplicationName = dataSet.First().ApplicationName,
                        StartedOn = dataSet.First().StartedOn,
                        CreatedOn = dataSet.First().CreatedOn,
                        UpdatedOn =  dataSet.First().UpdatedOn,
                         EndedOn =  dataSet.First().EndedOn,
                        Description = dataSet.First().Description
                    }
                };
                PageResponse<RunningApplicationResponse> obj = new PageResponse<RunningApplicationResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };
                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }

        [Fact]
        public void GetGraphicDataNew_Success()
        {
            try
            {
                SearchRequest<GraphDetailsRequest> searchRequest = new SearchRequest<GraphDetailsRequest>()
                {
                    Filter = new GraphDetailsRequest()
                    {
                        RequestTime = DateTime.Now
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                };
                var dataSet = new List<GraphDetail>()
                {
                    new GraphDetail()
                    {
                       ActiveLoginCount = 1,
                       LoginCount =1,
                       EndTime = DateTime.Now
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetGraphicData(It.IsAny<SearchRequest<GraphDetailsRequest>>(), It.IsAny<JwtTokenDetail>())).Returns(dataSet);
                var response = _userTrackerServiceMock.GetGraphicData(searchRequest, GetJwtUser());
                var dataSet1 = new List<GraphDetailsResponse>()
                {
                    new GraphDetailsResponse()
                    {

                        ActiveLoginCount = dataSet.First().ActiveLoginCount,
                        LoginCount = dataSet.First().LoginCount,
                        EndTime = dataSet.First().EndTime

                    }
                };
                PageResponse<GraphDetailsResponse> obj = new PageResponse<GraphDetailsResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };
                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }
        }

        [Fact]
        public void GetDashboardDataNew_Success()
        {
            try
            {
                SearchRequest<DashboardDetailsRequest> searchRequest = new SearchRequest<DashboardDetailsRequest>()
                {
                    Filter = new DashboardDetailsRequest()
                    {                       
                        RequestStartDate = DateTime.Now,
                        RequestEndDate = DateTime.Now
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                };
                var dataSet = new List<DashboardDetails>()
                {
                    new DashboardDetails()
                    {
                       Device = "Window-PC",
                       Version = "1.0.0.1",
                       EmpCode = "16235",
                       LoginTime = DateTime.Now,
                       SleepCount =1,
                       IdleCount =1,
                       ActiveCount =1,
                       TotalUsageCount =1,
                       TotalActiveUsers = 1,
                       TotalUsers = 1

                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetDashboardData(It.IsAny<SearchRequest<DashboardDetailsRequest>>(), It.IsAny<JwtTokenDetail>())).Returns(dataSet);
                var response = _userTrackerServiceMock.GetDashboardData(searchRequest, GetJwtUser());
                var dataSet1 = new List<DashboardDetailsResponse>()
                {
                    new DashboardDetailsResponse()
                    {

                        Device = dataSet.First().Device,
                        Version = dataSet.First().Version,
                        EmpCode = dataSet.First().EmpCode,
                        LoginTime = dataSet.First().LoginTime,
                        SleepCount = dataSet.First().SleepCount,
                        IdleCount = dataSet.First().IdleCount,
                        ActiveCount = dataSet.First().ActiveCount,
                        TotalUsageCount = dataSet.First().TotalUsageCount,
                        TotalActiveUsers = dataSet.First().TotalActiveUsers,
                        TotalActiveUsersToday = dataSet.First().TotalActiveUsersToday
                    }
                };
                PageResponse<DashboardDetailsResponse> obj = new PageResponse<DashboardDetailsResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };
                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }
        }


        [Fact]
        public void GetUserProfileDataNew_Success()
        {
            try
            {
                SearchRequest<UserProfileRequest> searchRequest = new SearchRequest<UserProfileRequest>()
                {
                    Filter = new UserProfileRequest()
                    {
                        RequestDateStart = DateTime.Now,
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                };
                var dataSet = new List<UserProfile>()
                {
                    new UserProfile()
                    {
                        EmpCode = "15505",
                        TotalActive = 0,
                        TotalIdle = 0,
                        TotalSleep = 0,
                        last_work_logged_on = DateTime.Now,
                        CreatedOn = DateTime.Now,
                        Total_Records = 0,
                        Total_Pages = 0,
                        EmployeeName="",
                        Location="Noida",
                        Department = "IT"
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetUserProfileData(It.IsAny<SearchRequest<UserProfileRequest>>(), It.IsAny<JwtTokenDetail>())).Returns(dataSet);
                var response = _userTrackerServiceMock.GetUserProfileData(searchRequest, GetJwtUser());
                var dataSet1 = new List<UserProfileResponse>()
                {
                    new UserProfileResponse()
                    {
                        EmpCode = dataSet.First().EmpCode,
                        TotalActive = dataSet.First().TotalActive,
                        TotalIdle = dataSet.First().TotalIdle,
                        TotalSleep = dataSet.First().TotalSleep,
                        last_work_logged_on = dataSet.First().last_work_logged_on,
                        CreatedOn = dataSet.First().CreatedOn,
                        EmployeeName = dataSet.First().EmployeeName,
                        Location = dataSet.First().Location,
                        Department= dataSet.First().Department
                    }
                };
                PageResponse<UserProfileResponse> obj = new PageResponse<UserProfileResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }


        [Fact]
        public void GetAllActivity_Success()
        {
            try
            {
                int Type = 1;
                var dataSet = new List<ActivityDetails>()
                {
                    new ActivityDetails()
                    {
                       Id=1,
                       Name="Test",
                       Type =1,
                       UniqueId=1
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetAllActivity(Type, It.IsAny<JwtTokenDetail>())).Returns(dataSet); var response = _userTrackerServiceMock.GetAllActivity(Type, GetJwtUser());
                var dataSet1 = new List<ActivityDetailsResponse>()
                {
                    new ActivityDetailsResponse()
                    {
                        Id = dataSet.First().Id,
                        Name = dataSet.First().Name,
                        Type = dataSet.First().Type

                    }
                };


                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }

        [Fact]
        public void GetUserActivityDetailsNew_Success()
        {
            try
            {
                SearchRequest<UserActivityDetailsRequest> searchRequest = new SearchRequest<UserActivityDetailsRequest>()
                {
                    Filter = new UserActivityDetailsRequest()
                    {
                        Activity = "Sleep",
                        LoginTime = null,
                        LogoutTime = null
                    },
                    IgnorePaging = false,
                    PageNumber = 1,
                    PageSize = 10,
                    SearchText = "",
                };
                var dataSet = new List<UserActivityDetails>()
                {
                    new UserActivityDetails()
                    {
                       Id = 15021,
                        EmpCode = "15505",
                        LoginTime = DateTime.Now,
                        LogoutTime = DateTime.Now,
                        SystemStatus = "",
                        IpAddress = "",
                        Total_Records = 0,
                        Total_Pages = 0
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetUserActivityDetails(It.IsAny<SearchRequest<UserActivityDetailsRequest>>(), It.IsAny<JwtTokenDetail>())).Returns(dataSet);
                var response = _userTrackerServiceMock.GetUserActivityDetails(searchRequest, GetJwtUser());
                var dataSet1 = new List<UserActivityDetailsResponse>()
                {
                    new UserActivityDetailsResponse()
                    {
                        Id = dataSet.First().Id,
                        EmpCode = dataSet.First().EmpCode,
                        LoginTime = dataSet.First().LoginTime,
                        LogoutTime = dataSet.First().LogoutTime,
                        SystemStatus = dataSet.First().SystemStatus,
                        IpAddress = dataSet.First().IpAddress,
                        CreatedOn = DateTime.Now,
                        UpdatedOn = DateTime.Now

                    }
                };
                PageResponse<UserActivityDetailsResponse> obj = new PageResponse<UserActivityDetailsResponse>
                {
                    PageSize = 1,
                    Records = dataSet1,
                    TotalPages = 1,
                    TotalRecords = 1,
                    CurrentPage = 1
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }

        }


        [Fact]
        public void GetApplicationActivityReportNew_Success()
        {
            try
            {
                ApplicationActivityReportRequest searchRequest = new ApplicationActivityReportRequest();
                {
                    searchRequest = new ApplicationActivityReportRequest()
                    {
                        EmpCode = "12345",
                        ChartType = "Sleep",
                        StartDate = null,
                        EndDate = null,
                        Device = "Windows",
                        Show = "Filter",
                        Type = "Applications"
                    };
                };
                var dataSet = new List<ApplicationActivityReportResult>()
                {
                   new ApplicationActivityReportResult
                   {
                     TotalCount = 0,
                     Results = new List<ApplicationActivityReport>() // Assuming Results can be empty or null
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetApplicationActivityReport(It.IsAny<ApplicationActivityReportRequest>(), It.IsAny<JwtTokenDetail>()))
                                     .Returns(dataSet);
                var response = _userTrackerServiceMock.GetApplicationActivityReport(searchRequest, GetJwtUser());
                var dataSet1 = new List<ApplicationActivityReportResponseResult>()
                {
                    new ApplicationActivityReportResponseResult()
                    {
                      TotalCount =0,
                      Results = new List<ApplicationActivityReportResponse>()
                    }
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.False(false);
            }

        }

        [Fact]
        public void GetCallsActivityReportNew_Success()
        {
            try
            {
                CallsActivityReportRequest searchRequest = new CallsActivityReportRequest();
                {
                    searchRequest = new CallsActivityReportRequest()
                    {
                        EmpCode = "12345",
                        ChartType = "Sleep",
                        StartDate = null,
                        EndDate = null,
                        Device = "Windows",
                        Show = "Filter",
                        Type = "Calls"
                    };
                };
                var dataSet = new List<CallsActivityReportResult>()
                {
                   new CallsActivityReportResult
                   {
                     TotalCount = 0,
                     Results = new List<CallsActivityReport>() // Assuming Results can be empty or null
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetCallsActivityReport(It.IsAny<CallsActivityReportRequest>(), It.IsAny<JwtTokenDetail>()))
                                     .Returns(dataSet);
                var response = _userTrackerServiceMock.GetCallsActivityReport(searchRequest, GetJwtUser());
                var dataSet1 = new List<CallsActivityReportResponseResult>()
                {
                    new CallsActivityReportResponseResult()
                    {
                      TotalCount =0,
                      Results = new List<CallsActivityReportResponse>()
                    }
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.False(false);
            }

        }



        [Fact]
        public void GetSeesionsActivityReportNew_Success()
        {
            try
            {
                SessionActivityReportRequest searchRequest = new SessionActivityReportRequest();
                {
                    searchRequest = new SessionActivityReportRequest()
                    {
                        EmpCode = "12345",
                        StartedOn = DateTime.UtcNow,
                        EndedOn = DateTime.UtcNow,
                        Device = "Windows",
                        ChartType = "Sleep"
                    };
                };
                var dataSet = new List<SessionActivityReportResult>()
                {
                   new SessionActivityReportResult
                   {
                     TotalCount = 0,
                     Results = new List<SessionActivityReport>() // Assuming Results can be empty or null
                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetSessionsActivityReport(It.IsAny<SessionActivityReportRequest>(), It.IsAny<JwtTokenDetail>()))
                                     .Returns(dataSet);
                var response = _userTrackerServiceMock.GetSessionsActivityReport(searchRequest, GetJwtUser());
                var dataSet1 = new List<SessionActivityReportResponseResult>()
                {
                    new SessionActivityReportResponseResult()
                    {
                      TotalCount =0,
                      Results = new List<SessionActivityReportResponse>()
                    }
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.False(false);
            }

        }


        [Fact]

        public void GetLogInActivityReportNew_Success()
        {
            try
            {
                LogInActivityReportRequest searchRequest = new LogInActivityReportRequest();
                {
                    searchRequest = new LogInActivityReportRequest()
                    {
                        EmpCode = "12345",
                        StartedOn = DateTime.UtcNow,
                        EndedOn = DateTime.UtcNow,
                        ChartType = "Active"
                    };
                };
                var dataSet = new List<LogInActivityReportResult>()
                {
                   new LogInActivityReportResult
                   {
                     Results = new List<LogInActivityReport>() // Assuming Results can be empty or null
                   }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetLogInActivityReport(It.IsAny<LogInActivityReportRequest>(), It.IsAny<JwtTokenDetail>()))
                                     .Returns(dataSet);
                var response = _userTrackerServiceMock.GetLogInActivityReport(searchRequest, GetJwtUser());
                var dataSet1 = new List<LogInActivityReportResponseResult>()
                {
                    new LogInActivityReportResponseResult()
                    {
                       Results = new List<LogInActivityReportResponse>()
                    }
                };

                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.False(false);
            }

        }


        [Fact]
        public void GetReportActivity_Success()
        {
            try
            {
                var dataSet = new List<ReportActivityDetailsResults>()
                {
                    new ReportActivityDetailsResults()
                    {
                       ParentId = 1,
                       ParentName = "Test"

                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetReportActivity(GetJwtUser())).Returns(dataSet);
                var response = _userTrackerServiceMock.GetReportActivity(GetJwtUser());
                var dataSet1 = new List<ReportActivityDetailsResults>()
                {
                    new ReportActivityDetailsResults()
                    {

                       ParentId= 1,
                       ParentName = "Test"
                    }
                };


                var result = false;
                Assert.False(result);
            }
            catch (Exception)
            {
                Assert.False(false);
            }

        }

        /*[Fact]
        public void GetAllUserNew_Success()
        {
            try
            {
                SearchRequestResponse<AllUserDetailsRequest> searchRequest = new SearchRequestResponse<AllUserDetailsRequest>()
                {
                    Filter = new AllUserDetailsRequest()
                    {
                        SortColumn = "user_id",
                        SortDirection = "DESC",
                        FilterColumn = "user_id",
                        FilterValue = "user_id"
                    },

                    PageNumber = 1,
                    PageSize = 10,

                };
                var record = new List<AllUserDetails>()
                {
                    new AllUserDetails()
                    {
                     user_id = 10,
                    user_first_name ="Saurabh",
                    user_last_name = "Yadav",
                    user_email = "ABC@gmail.com",
                    user_status = "1",
                    user_role_id = 1,
                    is_active = 1,
                    is_deleted = 1,
                    created_on = DateTime.Now,
                    updated_on = DateTime.Now

                    }
                };
                JwtTokenDetail userDetails = GetJwtUser() ?? throw new UnauthorisedException("Not a valid user");

                _providerMock.Setup(p => p.GetAllUser(It.IsAny<SearchRequestResponse<UserDetailedRequest>>())).Returns(record);
                var response = _userTrackerServiceMock.GetAllUser(searchRequest, GetJwtUser());
                var dataSet1 = new List<AllUserDetailsResponse>()
                {
                    new AllUserDetailsResponse()
                    {

                          user_id = record.First().user_id,
                            user_first_name = record.First().user_first_name,
                          user_last_name = record.First().user_last_name,
                             user_email = record.First().user_email,
                        user_status = record.First().user_status,
                           user_role_id = record.First().user_role_id,
                            is_active = record.First().is_active,
                            is_deleted = record.First().is_deleted,
                            created_on = record.First().created_on,
                            updated_on = record.First().updated_on
                    }
                };
                PageResponseRequest<AllUserDetailsResponse> obj = new PageResponseRequest<AllUserDetailsResponse>
                {
                   Records = dataSet1,
                   
                };
                var result = true;
                Assert.True(result);
            }
            catch (Exception)
            {
                Assert.True(false);
            }
        }
*/
    }
}

