Remove() public method

public Remove ( string packageId ) : IServiceResult
packageId string
return IServiceResult
        public void Remove_PackageListIsEmpty_ResultIsFalse()
        {
            // Arrange
            string packageId = "Package.A";

            var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory };
            var packageInfoFilesystemPersistence = new Mock<IFilesystemPersistence<PackageInfo[]>>();

            var packages = new PackageInfo[] { };
            packageInfoFilesystemPersistence.Setup(p => p.Load(It.IsAny<string>())).Returns(packages);

            var packageConfigurationAccessor = new PackageConfigurationAccessor(applicationInformation, packageInfoFilesystemPersistence.Object);

            // Act
            var result = packageConfigurationAccessor.Remove(packageId);

            // Assert
            Assert.AreEqual(result.Status, ServiceResultType.Failure);
        }
        public void Remove_PackageListContainsSuppliedPackageId_EmptyListIsSaved()
        {
            // Arrange
            string packageId = "Package.A";

            var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory };
            var packageInfoFilesystemPersistence = new Mock<IFilesystemPersistence<PackageInfo[]>>();

            var packages = new[]
                {
                    new PackageInfo { Id = "Package.A", Version = "1.0.0.0" }
                };
            packageInfoFilesystemPersistence.Setup(p => p.Load(It.IsAny<string>())).Returns(packages);

            var packageConfigurationAccessor = new PackageConfigurationAccessor(applicationInformation, packageInfoFilesystemPersistence.Object);

            // Act
            packageConfigurationAccessor.Remove(packageId);

            // Assert
            packageInfoFilesystemPersistence.Verify(p => p.Save(It.Is<PackageInfo[]>(packageList => !packageList.Any()), It.IsAny<string>()), Times.Once());
        }
        public void Remove_PackageListContainsSuppliedPackageId_SaveSucceeds_ResultIsTrue()
        {
            // Arrange
            string packageId = "Package.A";

            var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory };
            var packageInfoFilesystemPersistence = new Mock<IFilesystemPersistence<PackageInfo[]>>();

            var packages = new[]
                {
                    new PackageInfo { Id = "Package.A", Version = "1.0.0.0" }
                };
            packageInfoFilesystemPersistence.Setup(p => p.Load(It.IsAny<string>())).Returns(packages);

            packageInfoFilesystemPersistence.Setup(p => p.Save(It.IsAny<PackageInfo[]>(), It.IsAny<string>())).Returns(true);

            var packageConfigurationAccessor = new PackageConfigurationAccessor(applicationInformation, packageInfoFilesystemPersistence.Object);

            // Act
            var result = packageConfigurationAccessor.Remove(packageId);

            // Assert
            Assert.AreEqual(result.Status, ServiceResultType.Success);
        }
        public void Remove_PackageIdIsInvalid_ArgumentExceptionIsThrown(string packageId)
        {
            // Arrange
            var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory };
            var packageInfoFilesystemPersistence = new Mock<IFilesystemPersistence<PackageInfo[]>>();

            var packageConfigurationAccessor = new PackageConfigurationAccessor(applicationInformation, packageInfoFilesystemPersistence.Object);

            // Act
            packageConfigurationAccessor.Remove(packageId);
        }