Exemple #1
0
        public void AddArchivialNetworkSourceCommand_ThrowsErrorIfSourceFolderAndFileMatchExists()
        {
            var mockedDb = new Mock <IClientDatabase>();

            mockedDb.Setup(x => x.GetSourceLocationsAsync()).ReturnsAsync(
                new SourceLocations()
            {
                new NetworkSourceLocation()
                {
                    Path            = "\\\\network\\path\\to\\folder",
                    FileMatchFilter = "*"
                }
            }
                );

            var mockedCoreSettings = new Mock <ICoreSettings>();

            var depedencies = new CmdletDependencies()
            {
                ClientDatabase = mockedDb.Object,
                CoreSettings   = mockedCoreSettings.Object
            };

            var command = new AddArchivialNetworkSourceCommand(depedencies)
            {
                UncPath        = "\\\\network\\path\\to\\folder",
                MatchFilter    = "*",
                Priority       = "Low",
                Revisions      = 1,
                CredentialName = "creds"
            };

            var result = command.Invoke().GetEnumerator().MoveNext();
        }
Exemple #2
0
        public void AddArchivialNetworkSourceCommand_CanSaveNewNetworkSource()
        {
            var mockedDb = new Mock <IClientDatabase>();

            NetworkSourceLocation databaseCommitedObject = null;

            mockedDb.Setup(x => x.GetSourceLocationsAsync()).ReturnsAsync(new SourceLocations());

            mockedDb.Setup(x => x.SetSourceLocationAsync(It.IsAny <NetworkSourceLocation>()))
            .Returns(Task.CompletedTask)
            .Callback <NetworkSourceLocation>(x => databaseCommitedObject = x);

            var mockedCoreSettings = new Mock <ICoreSettings>();

            var depedencies = new CmdletDependencies()
            {
                ClientDatabase = mockedDb.Object,
                CoreSettings   = mockedCoreSettings.Object
            };

            var command = new AddArchivialNetworkSourceCommand(depedencies)
            {
                UncPath        = "\\\\network\\path\\to\\folder",
                Priority       = "Low",
                Revisions      = 1,
                MatchFilter    = "*",
                CredentialName = "creds"
            };

            var result = command.Invoke().GetEnumerator().MoveNext();

            mockedDb.Verify(x => x.SetSourceLocationAsync(It.IsAny <NetworkSourceLocation>()), Times.Once);

            Assert.IsNotNull(databaseCommitedObject);
            Assert.AreEqual("\\\\network\\path\\to\\folder", databaseCommitedObject.Path);
            Assert.AreEqual(FileBackupPriority.Low, databaseCommitedObject.Priority);
            Assert.AreEqual(1, databaseCommitedObject.RevisionCount);
            Assert.AreEqual("*", databaseCommitedObject.FileMatchFilter);
        }