Beispiel #1
0
        public void CallUpdateMethod_WhenPassedPackageExistsWithLowerVersionVersion()
        {
            // arrange
            var loggerMock = new Mock <ILogger>();

            loggerMock.Setup(x => x.Log(It.Is <string>(y => y.Contains("same version is already installed"))));

            string packageName    = "someName";
            var    presentPackage = new Mock <IPackage>();

            presentPackage.Setup(x => x.Name).Returns(packageName);
            var packages = new List <IPackage>()
            {
                presentPackage.Object
            };

            var packageRepository = new FakePackageRepository(loggerMock.Object, packages);

            var packageToAdd = new Mock <IPackage>();

            packageToAdd.Setup(x => x.Name).Returns(packageName);
            packageToAdd.Setup(x => x.CompareTo(It.IsAny <IPackage>()))
            .Returns(1);

            // act
            packageRepository.Add(packageToAdd.Object);

            // assert
            Assert.IsTrue(packageRepository.IsUpdateCalled);
        }
Beispiel #2
0
        public void AddPackageToPackages_WhenPackageDoesNotExistInThePackagesCollection()
        {
            // arrange
            var loggerStub = new Mock <ILogger>();

            var packages = new List <IPackage>();

            var packageRepository = new FakePackageRepository(loggerStub.Object, packages);

            var packageToAdd = new Mock <IPackage>();

            // act
            packageRepository.Add(packageToAdd.Object);

            // assert
            Assert.AreSame(packageToAdd.Object, packageRepository.Packages.First());
        }