Ejemplo n.º 1
0
 public void Parse_InvalidVersions(string version)
 {
     Assert.Throws <VersionParsingException>(() =>
     {
         DependencyVersion.Parse(version);
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the versions.
        /// </summary>
        /// <returns>
        /// Returns an enumerable with the MongoDb versions.
        /// </returns>
        /// <exception cref="NAMEException">Thrown when an unexpected exception happens.</exception>
        public override async Task <IEnumerable <DependencyVersion> > GetVersions()
        {
            var    versions = new List <DependencyVersion>();
            string connectionString;

            if (!this.connectionStringProvider.TryGetConnectionString(out connectionString))
            {
                throw new ConnectionStringNotFoundException(this.connectionStringProvider.ToString());
            }

            var connectionStringBuilder = new MongoConnectionStringBuilder(connectionString);

            byte[] message = this.CreateServerStatusMessagePayload(connectionStringBuilder);

            foreach (var mongoEndpoint in connectionStringBuilder.Servers)
            {
                using (var client = await this.OpenTcpClient(mongoEndpoint.Host, mongoEndpoint.Port, SupportedDependencies.MongoDb.ToString()))
                {
                    await client.GetStream().WriteAsync(message, 0, message.Length, default(CancellationToken)).ConfigureAwait(false);

                    await Task.Delay(100).ConfigureAwait(false);

                    BSONObject obj = ExtractServerStatusFromResponse(client);
                    versions.Add(DependencyVersion.Parse(obj["version"].stringValue));
                }
            }

            return(versions);
        }
        public void Translate_Versions(SqlServerVersions exptectedVersion, string versionStr)
        {
            IVersionTranslator translator = new SqlServerVersionTranslator();

            string v = translator.Translate(DependencyVersion.Parse(versionStr));

            Assert.True(v == exptectedVersion.ToString());
        }
        public void Translate_SqlServerVersions(SqlServerVersions version, string expectedVersion)
        {
            IVersionTranslator translator = new SqlServerVersionTranslator();

            DependencyVersion v = translator.Translate(version.ToString());

            Assert.True(v >= DependencyVersion.Parse(expectedVersion));
        }
        public async Task GetVersions_SpecificVersion_UriWithQueryString()
        {
            MongoDbVersionResolver resolver = new MongoDbVersionResolver(new StaticConnectionStringProvider($"mongodb://{ Constants.SpecificMongoHostname }:27017/?w=1"), 10000, 10000);

            var versions = await resolver.GetVersions().ConfigureAwait(false);

            Assert.Equal(1, versions.Count());
            Assert.Equal(versions.First(), DependencyVersion.Parse(Constants.SpecificMongoVersion));
        }
        public async Task GetVersions_LatestVersion()
        {
            MongoDbVersionResolver resolver = new MongoDbVersionResolver(new StaticConnectionStringProvider($"mongodb://{ Constants.LatestMongoHostname }:27017"), 10000, 10000);

            var versions = await resolver.GetVersions().ConfigureAwait(false);

            Assert.Equal(1, versions.Count());
            Assert.True(versions.First() >= DependencyVersion.Parse("3.0.0"));
        }
Ejemplo n.º 7
0
        public async Task GetVersions_MultipleConnectionStrings()
        {
            string           connectionString = $"amqp://*****:*****@{ Constants.SpecificRabbitHostname }:5672/, amqp://gibberish:notneeded@{ Constants.LatestRabbitHostname }:5672/";
            IVersionResolver resolver         = new RabbitMqVersionResolver(new StaticConnectionStringProvider(connectionString), 10000, 10000);

            var versions = await resolver.GetVersions().ConfigureAwait(false);

            Assert.Equal(2, versions.Count());
            Assert.Equal(versions.First(), DependencyVersion.Parse(Constants.SpecificRabbitVersion));
        }
Ejemplo n.º 8
0
        public async Task GetVersions_LatestVersion()
        {
            string           connectionString = $"amqp://*****:*****@{ Constants.LatestRabbitHostname }:5672/";
            IVersionResolver resolver         = new RabbitMqVersionResolver(new StaticConnectionStringProvider(connectionString), 10000, 10000);

            var versions = await resolver.GetVersions().ConfigureAwait(false);

            Assert.Equal(1, versions.Count());
            Assert.True(versions.First() >= DependencyVersion.Parse("3.6.5"));
        }
Ejemplo n.º 9
0
        public async Task GetVersions_SpecificPort()
        {
            string           connectionString = $"Data Source={ Constants.LatestSqlServerHostname },1433;Initial Catalog=DBTests;Integrated Security=True;";
            IVersionResolver resolver         = new SqlServerVersionResolver(new StaticConnectionStringProvider(connectionString), 10000, 10000);

            var versions = await resolver.GetVersions().ConfigureAwait(false);

            Assert.Equal(1, versions.Count());
            Assert.True(versions.First() >= DependencyVersion.Parse("12.0.0"), "The version should be greater than 12.0.0");
        }
Ejemplo n.º 10
0
        public async Task GetVersions_WrongEndpoint()
        {
            string           connectionString = $"http://{ Constants.SpecificServiceHostname }:5000/api/v1";
            IVersionResolver resolver         = new ServiceVersionResolver(new StaticConnectionStringProvider(connectionString), 0, 5, 10000, 10000);

            var versions = await resolver.GetVersions().ConfigureAwait(false);

            Assert.Equal(1, versions.Count());
            Assert.Equal(versions.First(), DependencyVersion.Parse(Constants.SpecificServiceVersion));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the version of the SQL Server.
        /// </summary>
        /// <returns>
        /// Returns an enumerable with a single element containing the version of the SQL Server.
        /// </returns>
        /// <exception cref="NAMEException">An unexpected exception happened. See inner exception for details.</exception>
        public override async Task <IEnumerable <DependencyVersion> > GetVersions()
        {
            string hostname;
            int    port;

            this.ExtractHostnameAndPort(out hostname, out port);

            byte[] message = this.CreatePreLoginMessage();

            using (var client = await this.OpenTcpClient(hostname, port, SupportedDependencies.SqlServer.ToString()))
            {
                await client.GetStream().WriteAsync(message, 0, message.Length, default(CancellationToken)).ConfigureAwait(false);

                string versionStr = this.GetServerVersionFromResponse(client.GetStream());
                return(new List <DependencyVersion> {
                    DependencyVersion.Parse(versionStr)
                });
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets the versions.
        /// </summary>
        /// <returns>
        /// Returns an enumerable with only an item, containing the RabbitMq version.
        /// </returns>
        /// <exception cref="NAMEException">An unexpected exception happened. See inner exception for details.</exception>
        public override async Task <IEnumerable <DependencyVersion> > GetVersions()
        {
            string rabbitConnectionString;

            if (!this.connectionStringProvider.TryGetConnectionString(out rabbitConnectionString))
            {
                throw new ConnectionStringNotFoundException(this.connectionStringProvider.ToString());
            }

            var result = new List <DependencyVersion>();

            foreach (string connectionString in rabbitConnectionString.Split(','))
            {
                Uri rabbitMQUri = new Uri(connectionString.Trim());
                using (var client = await this.OpenTcpClient(rabbitMQUri.Host, rabbitMQUri.Port, SupportedDependencies.RabbitMq.ToString()).ConfigureAwait(false))
                {
                    SendConnectionHeader(client);
                    string version = GetVersionFromServerReponse(client);
                    result.Add(DependencyVersion.Parse(version));
                }
            }
            return(result);
        }
        public void Translate_Versions(WindowsVersions exptectedVersion, string versionStr)
        {
            IVersionTranslator translator = new WindowsVersionTranslator();

            string v = translator.Translate(new OperatingSystemDependencyVersion("windows", DependencyVersion.Parse(versionStr)));

            Assert.True(v == exptectedVersion.ToString());
        }