示例#1
0
        public void InstantiatePackage_IfPackageDoesntExist()
        {
            var packages = new Mock <ICollection <IPackage> >();
            var logger   = new Mock <ILogger>();

            var packageRepository = new PackageRepositoryFake(logger.Object, null);

            Assert.IsInstanceOf <ICollection <IPackage> >(packageRepository.PackagesFake);
        }
示例#2
0
        public void ThrowArgumentNullException_WhenPassedNullPackage()
        {
            var package  = new Mock <IPackage>();
            var logger   = new Mock <ILogger>();
            var packages = new List <IPackage>()
            {
                package.Object
            };

            var packageRepository = new PackageRepositoryFake(logger.Object, packages);

            Assert.Throws <ArgumentNullException>(() => packageRepository.Delete(package.Object), null);
        }
示例#3
0
        public void ThrowArgumentNullException_WhenLoggerValueIsNull()
        {
            var package  = new Mock <IPackage>();
            var logger   = new Mock <ILogger>();
            var packages = new List <IPackage>()
            {
                package.Object
            };

            var packageRepository = new PackageRepositoryFake(logger.Object, packages);

            Assert.Throws <ArgumentNullException>(() => new PackageRepositoryFake(null, packages));
        }
示例#4
0
        public void TestValidPackage()
        {
            var package = new Mock <IPackage>();

            package.Setup(x => x.Name).Returns("name");
            var logger   = new Mock <ILogger>();
            var packages = new List <IPackage>()
            {
                package.Object
            };

            var packageRepository = new PackageRepositoryFake(logger.Object, packages);

            Assert.Throws <ArgumentNullException>(() => packageRepository.Delete(package.Object), "not exist");
        }
示例#5
0
        public void SetCorrectLoggerValue_WhenValueIsNotNull()
        {
            var package  = new Mock <IPackage>();
            var logger   = new Mock <ILogger>();
            var packages = new List <IPackage>()
            {
                package.Object
            };

            var packageRepository = new PackageRepositoryFake(logger.Object, packages);

            packageRepository.Add(package.Object);

            Assert.AreEqual(logger.Object, packageRepository.LoggerFake);
        }
示例#6
0
        public void SetCorrectPackageValue()
        {
            var package  = new Mock <IPackage>();
            var logger   = new Mock <ILogger>();
            var packages = new List <IPackage>()
            {
                package.Object
            };

            var packageRepository = new PackageRepositoryFake(logger.Object, packages);

            packageRepository.Add(package.Object);

            Assert.AreEqual(packages, packageRepository.PackagesFake);
        }