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

            NetworkSourceLocation databaseCommitedObject = null;

            mockedDb.Setup(x => x.GetSourceLocationsAsync()).ReturnsAsync(
                new SourceLocations()
            {
                new NetworkSourceLocation()
                {
                    ID = 1
                }
            }
                );

            mockedDb.Setup(x => x.RescanSourceLocationAsync(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 StartArchivialNetworkSourceRescanCommand(depedencies)
            {
                SourceID = 2
            };

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

            NetworkSourceLocation databaseCommitedObject = null;

            mockedDb.Setup(x => x.GetSourceLocationsAsync()).ReturnsAsync(
                new SourceLocations()
            {
                new NetworkSourceLocation()
                {
                    ID = 1
                }
            }
                );

            mockedDb.Setup(x => x.RescanSourceLocationAsync(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 StartArchivialNetworkSourceRescanCommand(depedencies)
            {
                NetworkSource = new NetworkSourceLocation()
                {
                    ID = 1
                }
            };

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

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

            Assert.IsNotNull(databaseCommitedObject);
            Assert.AreEqual(1, databaseCommitedObject.ID);
        }