Exemplo n.º 1
0
        private static async Task BackupAsync(IEnumerable <string> args)
        {
            if (args.Any() && args.First() == "-h")
            {
                DisplayBackupHelp();
            }
            else
            {
                var command    = new BackupCommand();
                var parameters = command.ReadParameters(args);

                if (parameters.ConfigPath == null)
                {
                    throw new CosbakException("Switch 'c' not specified, i.e. path to configuration");
                }
                else
                {
                    var configuration = await LoadBackupConfigurationAsync(parameters.ConfigPath);

                    var metaController = new MetaController();

                    await metaController.BackupAsync(configuration, parameters.Mode);
                }
            }
        }
Exemplo n.º 2
0
        public void GetTimeIdentifiersByCategory()
        {
            var controller = new MetaController(new MetaService());

            var result = controller.GetTimeIdentifiersByCategory();

            result.AssertOkResult();
        }
Exemplo n.º 3
0
        public void Get_TimeIdentifiersByCategory_Returns_Ok()
        {
            var metaService = new MetaService(null /* do not need */);
            var controller  =
                new MetaController(metaService);

            // Method under test
            var result = controller.GetTimeIdentifiersByCategory();

            Assert.IsAssignableFrom <List <TimeIdentifierCategoryModel> >(result.Value);
        }
Exemplo n.º 4
0
        public void ReturnsDataAboutDefinitions()
        {
            var definitions = new[]
            {
                Identifiers.Definitions.String("TestString"),
                Identifiers.Definitions.Enum("TestEnum", "Yes", "No")
            };
            var controller = new MetaController(new IdentifierDefinitionRegistry(definitions), null);

            var result = controller.Get();

            result.Should().BeOfType <OkObjectResult>()
            .Which
            .Value.Should().BeEquivalentTo(definitions);
        }
Exemplo n.º 5
0
        private static async Task BackupAsync(Container sourceContainer)
        {
            var metaController      = new MetaController();
            var backupConfiguration = new BackupConfiguration
            {
                CosmosAccount  = CosmosCollectionRental.CosmosConfiguration,
                StorageAccount = Storage.StorageConfiguration,
                Collections    = new[]
                {
                    new CollectionBackupPlanOverride
                    {
                        Db         = CosmosCollectionRental.DatabaseName,
                        Collection = sourceContainer.Id
                    }
                }
            };

            await metaController.BackupAsync(backupConfiguration, BackupMode.Iterative);
        }
Exemplo n.º 6
0
        public void Get_ReleaseTypes_Returns_Ok()
        {
            var metaService = new Mock <IMetaService>();

            metaService.Setup(s => s.GetReleaseTypes()).Returns(
                new List <ReleaseType>
            {
                new ReleaseType()
                {
                    Title = "Ad Hoc"
                }
            }
                );
            var controller = new MetaController(metaService.Object);

            // Method under test
            var result = controller.GetReleaseTypes();

            Assert.IsAssignableFrom <List <ReleaseType> >(result.Value);
        }
Exemplo n.º 7
0
        public MetaControllerTests()
        {
            var publicationMetaService = new Mock <IPublicationMetaService>();
            var themeMetaService       = new Mock <IThemeMetaService>();

            publicationMetaService
            .Setup(s => s.GetSubjectsForLatestRelease(_publicationId))
            .ReturnsAsync(new PublicationSubjectsMetaViewModel());

            publicationMetaService
            .Setup(s => s.GetSubjectsForLatestRelease(It.Is <Guid>(guid => guid != _publicationId)))
            .ReturnsAsync(new NotFoundResult());

            themeMetaService.Setup(s => s.GetThemes())
            .Returns(new List <ThemeMetaViewModel>
            {
                new ThemeMetaViewModel()
            });

            _controller = new MetaController(publicationMetaService.Object, themeMetaService.Object);
        }
Exemplo n.º 8
0
        private static async Task RestoreAsync(Container sourceContainer, Container targetContainer)
        {
            var metaController       = new MetaController();
            var restoreConfiguration = new RestoreConfiguration
            {
                CosmosAccount    = CosmosCollectionRental.CosmosConfiguration,
                StorageAccount   = Storage.StorageConfiguration,
                SourceCollection = new CompleteCollectionConfiguration
                {
                    Account    = CosmosCollectionRental.CosmosConfiguration.Name,
                    Db         = CosmosCollectionRental.DatabaseName,
                    Collection = sourceContainer.Id,
                },
                TargetCollection = new CollectionConfiguration
                {
                    Db         = CosmosCollectionRental.DatabaseName,
                    Collection = targetContainer.Id
                }
            };

            await metaController.RestoreAsync(restoreConfiguration);
        }