public void Delete_allTrue()
        {
            // Setup dependency
            var settingsMock = new Mock<ISettings>();
            var repositoryMock = new Mock<IRepository>();
            var uowMock = new Mock<IUnitOfWork>();
            var serviceLocatorMock = new Mock<IServiceLocator>();
            serviceLocatorMock.Setup(x => x.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange
            List<Log> logs = new List<Log>();
            bool isDeleteAll = true;

            LogLevel logLevel = LogLevel.Error;

            for (int i = 0; i < 20; i++)
            {
                logs.Add(new Log
                {
                    Message = i.ToString(),
                    Level = logLevel.ToString(),
                    Date = DateTime.UtcNow
                });
            }
            repositoryMock.Setup(r => r.Query<Log>()).Returns(logs.AsQueryable());

            // Act
            LogManagementService logAdminService = new LogManagementService(
                uowMock.Object, repositoryMock.Object, settingsMock.Object);
            logAdminService.Delete(isDeleteAll);

            // Assert
            repositoryMock.Verify(r => r.Delete<Log>(It.IsAny<Log>()));
            uowMock.Verify(u => u.Save());
        }
        public void Delete_DebugLog_DeleteInWeek_allFalse()
        {
            // Setup dependency
            var settingsMock = new Mock<ISettings>();
            var repositoryMock = new Mock<IRepository>();
            var uowMock = new Mock<IUnitOfWork>();
            var serviceLocatorMock = new Mock<IServiceLocator>();
            serviceLocatorMock.Setup(x => x.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange
            List<string> expectedResult = new List<string>();
            List<Log> logs = new List<Log>();
            bool isDeleteAll = false;

            LogLevel logLevel = LogLevel.Debug;

            for (int i = 0; i < 20; i++)
            {
                if (i < 10)
                {
                    logs.Add(new Log
                    {
                        Message = i.ToString(),
                        Level = logLevel.ToString().ToUpper(),
                        Date = DateTime.UtcNow.AddDays(-3)
                    });
                    expectedResult.Add(i.ToString());
                }
                else //Older Last week
                {
                    logs.Add(new Log
                    {
                        Message = i.ToString(),
                        Level = logLevel.ToString().ToUpper(),
                        Date = DateTime.UtcNow.AddDays(-8)
                    });
                }
            }
            repositoryMock.Setup(r => r.Query<Log>()).Returns(logs.AsQueryable());

            // Act
            LogManagementService logAdminService = new LogManagementService(
                uowMock.Object, repositoryMock.Object, settingsMock.Object);
            logAdminService.Delete(isDeleteAll);

            // Assert
            repositoryMock.Verify(r => r.Delete<Log>(It.IsAny<Log>()));
            repositoryMock.Verify(r => r.Delete<Log>(
                It.Is<Log>(l => !expectedResult.Contains(l.Message))));
            uowMock.Verify(u => u.Save());
        }
        public void Delete_NullData()
        {
            // Setup dependency
            var settingsMock = new Mock<ISettings>();
            var repositoryMock = new Mock<IRepository>();
            var uowMock = new Mock<IUnitOfWork>();
            var serviceLocatorMock = new Mock<IServiceLocator>();
            serviceLocatorMock.Setup(x => x.GetInstance<IRepository>())
                .Returns(repositoryMock.Object);
            ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object);

            // Arrange
            bool isDeleteAll = false;

            // Act
            LogManagementService logAdminService = new LogManagementService(
                uowMock.Object, repositoryMock.Object, settingsMock.Object);
            logAdminService.Delete(isDeleteAll);

            // Assert
            uowMock.Verify(u => u.Save());
        }