Exemple #1
0
        public async Task RestoreSucceeds()
        {
            var results = await this.controller.Restore(2);

            var result = await results.ExecuteAsync(CancellationToken.None);

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);

            var content = await result.Content.ReadAsStringAsync();

            this.configViews = new List <ConfigurationView>();

            var configView = new ConfigurationView(this.UrlHelper)
            {
                ConfigurationDocumentId = 3,
                Checksum           = this.TestConfigT1C1.Checksum,
                Id                 = this.TestConfigT1C1.Id,
                PublishedTimestamp = this.TestConfigT1C1.PublishedTimestamp,
                Target             = this.TestConfigT1C1.Target
            };

            var archiveViews = new List <ArchiveConfigurationView>();
            var archiveView  = this.TestConfigT1C1.Map <ArchiveConfigurationView>();

            archiveViews.Add(archiveView);

            configView.ArchiveConfigurations = archiveViews;
            configView.PopulateLinks();

            var resultContent = JsonConvert.SerializeObject(configView);

            Assert.AreEqual(resultContent, content);
        }
Exemple #2
0
        /// <summary>
        /// The initialize configuration view.
        /// </summary>
        private void InitializeConfigurationView()
        {
            this.configViews = new List <ConfigurationView>();
            var archiveViews = new List <ArchiveConfigurationView>();
            var configView   = new ConfigurationView(this.UrlHelper);



            foreach (var config in this.configs)
            {
                if (config.ArchiveTimestamp == null)
                {
                    configView.Checksum = config.Checksum;
                    configView.Id       = config.Id;
                    configView.Target   = config.Target;
                    configView.ConfigurationDocumentId = config.ConfigurationDocumentId;
                    configView.PublishedTimestamp      = config.PublishedTimestamp;

                    configView.PopulateLinks();
                }
                else
                {
                    var archiveView = new ArchiveConfigurationView(this.UrlHelper)
                    {
                        ArchiveTimestamp = config.ArchiveTimestamp ?? DateTime.UtcNow,
                        Checksum         = config.Checksum,
                        Id     = config.Id,
                        Target = config.Target,
                        ConfigurationDocumentId =
                            config.ConfigurationDocumentId,
                        PublishedTimestamp =
                            config.PublishedTimestamp
                    };
                    archiveView.PopulateLinks();
                    archiveViews.Add(archiveView);
                }

                configView.ArchiveConfigurations = archiveViews;
                this.configViews.Add(configView);
            }
        }
Exemple #3
0
        /// <summary>
        /// The initialize configuration view all.
        /// </summary>
        private void InitializeConfigurationViewAll()
        {
            this.configViews = new List <ConfigurationView>();

            var configView1 = new ConfigurationView(this.UrlHelper)
            {
                ConfigurationDocumentId = this.TestConfigT1C1.ConfigurationDocumentId,
                Checksum           = this.TestConfigT1C1.Checksum,
                Id                 = this.TestConfigT1C1.Id,
                PublishedTimestamp = this.TestConfigT1C1.PublishedTimestamp,
                Target             = this.TestConfigT1C1.Target
            };

            var archiveViews1 = new List <ArchiveConfigurationView>();
            var archiveView1  = this.TestConfigT1C2.Map <ArchiveConfigurationView>();

            archiveViews1.Add(archiveView1);

            configView1.ArchiveConfigurations = archiveViews1;
            configView1.PopulateLinks();

            this.configViews.Add(configView1);

            var configView2 = new ConfigurationView(this.UrlHelper)
            {
                ConfigurationDocumentId = this.TestConfigT2C1.ConfigurationDocumentId,
                Checksum           = this.TestConfigT2C1.Checksum,
                Id                 = this.TestConfigT2C1.Id,
                PublishedTimestamp = this.TestConfigT2C1.PublishedTimestamp,
                Target             = this.TestConfigT2C1.Target
            };

            var archiveViews2 = new List <ArchiveConfigurationView>();
            var archiveView2  = this.TestConfigT2C2.Map <ArchiveConfigurationView>();

            archiveViews2.Add(archiveView2);

            configView2.ArchiveConfigurations = archiveViews2;
            configView2.PopulateLinks();
            this.configViews.Add(configView2);
        }