Exemple #1
0
        public void GenerateMaxFiles_WhenCalled(string search, bool hasValues)
        {
            // Setup
            var folderHelperMock = new Mock <IFolderHelper>();

            // Using Ordinal since this is used with paths
            folderHelperMock.Setup(r => r.IsDriveOrSharedFolder(It.IsAny <string>()))
            .Returns <string>(s => s.StartsWith("C:", StringComparison.Ordinal));

            var itemResultMock = new Mock <IItemResult>();

            var internalDirectoryMock = new Mock <IQueryInternalDirectory>();

            internalDirectoryMock.Setup(r => r.Query(It.IsAny <string>()))
            .Returns(new List <IItemResult>()
            {
                itemResultMock.Object
            });

            var processor = new InternalDirectoryProcessor(folderHelperMock.Object, internalDirectoryMock.Object);

            // Act
            var results = processor.Results(string.Empty, search);

            // Assert
            if (hasValues)
            {
                Assert.IsTrue(results.Count() > 0);
            }
            else
            {
                Assert.IsTrue(results.Count() == 0);
            }
        }
        public void GenerateMaxFiles_WhenCalled(string search, bool hasValues)
        {
            // Setup
            var folderHelperMock = new Mock <IFolderHelper>();

            folderHelperMock.Setup(r => r.IsDriveOrSharedFolder(It.IsAny <string>()))
            .Returns <string>(s => s.StartsWith("C:", StringComparison.CurrentCultureIgnoreCase));

            var itemResultMock = new Mock <IItemResult>();

            var internalDirectoryMock = new Mock <IQueryInternalDirectory>();

            internalDirectoryMock.Setup(r => r.Query(It.IsAny <string>()))
            .Returns(new List <IItemResult>()
            {
                itemResultMock.Object
            });

            var processor = new InternalDirectoryProcessor(folderHelperMock.Object, internalDirectoryMock.Object);

            // Act
            var results = processor.Results(string.Empty, search);

            // Assert
            if (hasValues)
            {
                CollectionAssert.IsNotEmpty(results);
            }
            else
            {
                CollectionAssert.IsEmpty(results);
            }
        }