AddOrUpdate() 공개 메소드

public AddOrUpdate ( PackageInfo packageInfo ) : IServiceResult
packageInfo NuDeploy.Core.Common.PackageInfo
리턴 IServiceResult
        public void AddOrUpdate_PackageInfoParameterIsNull_ArgumentNullExceptionIsThrown()
        {
            // Arrange
            PackageInfo packageInfo = null;

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

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

            // Act
            packageConfigurationAccessor.AddOrUpdate(packageInfo);
        }
        public void AddOrUpdate_PackageInfoIsInvalid_ResultIsFalse()
        {
            // Arrange
            var packageInfo = new PackageInfo();

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

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

            // Act
            var result = packageConfigurationAccessor.AddOrUpdate(packageInfo);

            // Assert
            Assert.AreEqual(result.Status, ServiceResultType.Failure);
        }
        public void AddOrUpdate_PackageListIsEmpty_AddNewPackage_OnePackageIsSaved()
        {
            // Arrange
            var packageInfo = new PackageInfo { Id = "Package.A", Version = "1.0.0.0" };

            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
            packageConfigurationAccessor.AddOrUpdate(packageInfo);

            // Assert
            packageInfoFilesystemPersistence.Verify(
                p => p.Save(It.Is<PackageInfo[]>(packageList => packageList.Count() == 1 && packageList.Contains(packageInfo)), It.IsAny<string>()),
                Times.Once());
        }