/// <summary> /// Configures the mockups for the unit tests. /// </summary> private void SetupMocks() { IResult <IList <string> > listResult = new Result <IList <string> >() .SetReturnValue(new List <string>(new[] { string.Empty })); PlatformMock.Setup(p => p.ListFiles(It.IsAny <string>())) .Returns(listResult); PlatformMock.Setup(p => p.ListDirectories(It.IsAny <string>())) .Returns(listResult); Mock <IDirectories> directories = new Mock <IDirectories>(); directories.Setup(d => d.PackageArchives).Returns("archives"); directories.Setup(d => d.Packages).Returns("packages"); PlatformManagerMock.Setup(p => p.Platform).Returns(PlatformMock.Object); PlatformManagerMock.Setup(p => p.Directories).Returns(directories.Object); IResult <IPackageArchive> factoryArchiveResult = new Result <IPackageArchive>() .SetReturnValue(PackageArchiveMock.Object); IResult <IPackage> factoryPackageResult = new Result <IPackage>() .SetReturnValue(PackageMock.Object); PackageFactoryMock.Setup(p => p.GetPackageArchive(It.IsAny <string>())) .Returns(factoryArchiveResult); PackageFactoryMock.Setup(p => p.GetPackage(It.IsAny <string>())) .Returns(factoryPackageResult); }
public void ScanPackagesInvalidPackage() { PackageFactoryMock.Setup(p => p.GetPackage(It.IsAny <string>())) .Returns(new Result <IPackage>(ResultCode.Failure)); PackageScanner test = new PackageScanner(PlatformManagerMock.Object, PackageFactoryMock.Object); IResult <IList <IPackage> > result = test.ScanPackages(); Assert.Equal(ResultCode.Warning, result.ResultCode); Assert.Equal(0, result.ReturnValue.Count); }