Ejemplo n.º 1
0
        public void Should_ParseCorrectly_When_OnlyRequiredPropertiesAreThere()
        {
            var a =
                @"{
   ""host"": ""ea20d9d5-f69e-46ad-8eb1-f32f33a7472e.us-east-1.dse.datastax.com"",
   ""port"": 30443,
   ""localDC"": ""aws-us-east-1""
}";
            var stream = new MemoryStream(Encoding.Default.GetBytes(a));
            var target = new CloudConfigurationParser();

            var config = target.ParseConfig(stream);

            Assert.AreEqual(30443, config.Port);
            Assert.AreEqual("ea20d9d5-f69e-46ad-8eb1-f32f33a7472e.us-east-1.dse.datastax.com", config.Host);
        }
Ejemplo n.º 2
0
        public void Should_ThrowException_When_PortIsNotThere()
        {
            var a =
                @"{
   ""username"": ""joaoreis"",
   ""password"": ""joaoreis123"",
   ""host"": ""ea20d9d5-f69e-46ad-8eb1-f32f33a7472e.us-east-1.dse.datastax.com"",
   ""keyspace"": ""joaoreisks"",
   ""localDC"": ""aws-us-east-1""
}";
            var stream = new MemoryStream(Encoding.Default.GetBytes(a));
            var target = new CloudConfigurationParser();

            var ex = Assert.Throws <ArgumentException>(() => target.ParseConfig(stream));

            Assert.IsTrue(ex.Message.Contains("Could not parse the \"port\""), ex.Message);
        }
        public void Should_ThrowException_When_PortIsNotThere()
        {
            var randomString  = Guid.NewGuid().ToString().Replace("-", "");
            var randomString2 = Guid.NewGuid().ToString().Replace("-", "");
            var randomString3 = Guid.NewGuid().ToString().Replace("-", "");
            var a             =
                "{" +
                $"\"username\": \"{randomString}\"," +
                $"\"password\": \"{randomString2}\"," +
                "\"host\": \"ea20d9d5-f69e-46ad-8eb1-f32f33a7472e.us-east-1.dse.datastax.com\"," +
                $"\"keyspace\": \"{randomString3}\"," +
                "\"localDC\": \"aws-us-east-1\"" +
                "}";
            var stream = new MemoryStream(Encoding.Default.GetBytes(a));
            var target = new CloudConfigurationParser();

            var ex = Assert.Throws <ArgumentException>(() => target.ParseConfig(stream));

            Assert.IsTrue(ex.Message.Contains("Could not parse the \"port\""), ex.Message);
        }
Ejemplo n.º 4
0
        public void Should_ParseCorrectly_When_AllPropertiesAreThere()
        {
            var randomString  = Guid.NewGuid().ToString().Replace("-", "");
            var randomString2 = Guid.NewGuid().ToString().Replace("-", "");
            var randomString3 = Guid.NewGuid().ToString().Replace("-", "");
            var a             =
                @"{" +
                $"\"username\": \"{randomString}\"," +
                $"\"password\": \"{randomString2}\"," +
                "\"host\": \"ea20d9d5-f69e-46ad-8eb1-f32f33a7472e.us-east-1.dse.datastax.com\"," +
                "\"port\": 30443," +
                $"\"keyspace\": \"{randomString3}\"," +
                "\"localDC\": \"aws-us-east-1\"" +
                "}";
            var stream = new MemoryStream(Encoding.Default.GetBytes(a));
            var target = new CloudConfigurationParser();

            var config = target.ParseConfig(stream);

            Assert.AreEqual(30443, config.Port);
            Assert.AreEqual("ea20d9d5-f69e-46ad-8eb1-f32f33a7472e.us-east-1.dse.datastax.com", config.Host);
        }