public void WhenOnlyWhenTrueValue_AndIsFalse_ReturnsEmptyString()
        {
            var attribute = ArgumentsBuilderExtension.GetAutoPropertyAttributeOrNull(DecoratedBoolProperty);
            var actual    = ArgumentsBuilderExtension.GetArgumentFromAutoProperty(attribute, DecoratedBoolProperty, false);

            Assert.That(actual, Is.Empty);
        }
        public void WhenDecoratedStrings_FormatsProperly()
        {
            var attribute = ArgumentsBuilderExtension.GetAutoPropertyAttributeOrNull(DecoratedStringsProperty);
            var actual    = ArgumentsBuilderExtension.GetArgumentFromAutoProperty(attribute, DecoratedStringsProperty, new string[] { "One=1", "Two=2" });

            Assert.That(actual, Is.EqualTo("-e One=1 -e Two=2"));
        }
        public void WhenOnlyWhenTrueValue_AndIsTrue_FormatsProperly()
        {
            var attribute = ArgumentsBuilderExtension.GetAutoPropertyAttributeOrNull(DecoratedBoolProperty);
            var actual    = ArgumentsBuilderExtension.GetArgumentFromAutoProperty(attribute, DecoratedBoolProperty, true);

            Assert.That(actual, Is.EqualTo("-v"));
        }
            public void WhenGivenStringPropertyAndGivenParameter_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromStringProperty(StringProperty, "tubo",
                                                                                     parameter: new ParameterAttribute("-custom_name"));

                Assert.That(actual, Is.EqualTo("-custom_name=\"tubo\""));
            }
            public void WhenTrueAndParameter_UsesParameterName()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromNullableBoolProperty(NullableBoolProperty, true,
                                                                                           parameter: new ParameterAttribute("-custom_name"));

                Assert.That(actual, Is.EqualTo("-custom_name"));
            }
        public void WhenGivenValue_FormatsProperly()
        {
            var attribute = ArgumentsBuilderExtension.GetAutoPropertyAttributeOrNull(DecoratedStringProperty);
            var actual    = ArgumentsBuilderExtension.GetArgumentFromAutoProperty(attribute, DecoratedStringProperty, "SIGNAL");

            Assert.That(actual, Is.EqualTo("-s SIGNAL"));
        }
            public void WhenGivenStringArrayProperty_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromDictionaryProperty(StringsProperty, new Dictionary <string, string> {
                    { "t1", "v1" }, { "t2", "v2" }
                });

                Assert.AreEqual(actual.ToArray(), new string[] { "--strings \"t1=v1\"", "--strings \"t2=v2\"" });
            }
            public void WhenPortIsNotNullAndBindingAddressIsNull_ReturnsOnlyPort()
            {
                var actual = ArgumentsBuilderExtension.FromObservatorySettings(new ObservatorySettings {
                    Port = 99
                });

                Assert.That(actual, Is.EqualTo("=99"));
            }
            public void WhenPortIsNullAndBindingAddressIsNotNull_ReturnsNull()
            {
                var actual = ArgumentsBuilderExtension.FromObservatorySettings(new ObservatorySettings {
                    BindAddress = "10.0.0.0"
                });

                Assert.That(actual, Is.Null);
            }
Exemplo n.º 10
0
            public void WhenGivenStringProperty_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromStringProperty(StringProperty, "tubo", isSecret: true).Value;

                Assert.That(actual.Key, Is.EqualTo("--string"));
                Assert.That(actual.Value, Is.EqualTo("tubo"));
                Assert.That(actual.Quoting, Is.EqualTo(DockerArgumentQuoting.QuotedSecret));
            }
            public void WhenPassedMember_ExtractName()
            {
                TestEnum source = TestEnum.One;

                string actual = ArgumentsBuilderExtension.GetEnumName(typeof(TestEnum), source);

                Assert.That(actual, Is.EqualTo("one"));
            }
            public void WhenGivenStringArrayProperty_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromStringArrayProperty(StringsProperty, new string[] { "tubo1", "tubo2" }, isSecret: false);

                CollectionAssert.AreEqual(actual, new DockerArgument[] {
                    new DockerArgument("--strings", "tubo1", DockerArgumentQuoting.Quoted),
                    new DockerArgument("--strings", "tubo2", DockerArgumentQuoting.Quoted)
                });
            }
            public void WhenGivenValue_PropertyIsHandled()
            {
                TestSettings settings = new TestSettings {
                    Enum = TestEnum.One
                };
                var actual = ArgumentsBuilderExtension.GetArgumentFromProperty(EnumProperty, settings);

                Assert.That(actual.ToArray().Length, Is.EqualTo(1));
            }
            public void WhenPortAndBindingAddressAreNotNull_ReturnsCorrectlyFormated()
            {
                var actual = ArgumentsBuilderExtension.FromObservatorySettings(
                    new ObservatorySettings {
                    Port = 99, BindAddress = "10.0.0.0"
                });

                Assert.That(actual, Is.EqualTo("=99/10.0.0.0"));
            }
Exemplo n.º 15
0
        public void WhenPreCommand_ItAppearsInPreCommands()
        {
            TestSettings input = new TestSettings {
                PreCommandValue = "preCommand"
            };
            var actual = ArgumentsBuilderExtension.GetArgumentFromProperty(PreCommandValueProperty, input, preCommand: true, isSecret: false);

            Assert.That(actual.Count(), Is.EqualTo(1));
        }
Exemplo n.º 16
0
        public void WhenPreCommand_DoesNotAppearInNormalCommands()
        {
            TestSettings input = new TestSettings {
                PreCommandValue = "preCommand"
            };
            var actual = ArgumentsBuilderExtension.GetArgumentFromProperty(PreCommandValueProperty, input, preCommand: false, isSecret: false);

            Assert.That(actual.Count(), Is.Zero);
        }
            public void WhenGivenStringArrayProperty_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromStringArrayListProperty(
                    ListStringsProperty, new string[] { "tubo1", "tubo2" }, isSecret: false).Value;

                Assert.That(actual.Key, Is.EqualTo("--list-strings"));
                Assert.That(actual.Value, Is.EqualTo("tubo1,tubo2"));
                Assert.That(actual.Quoting, Is.EqualTo(DockerArgumentQuoting.Quoted));
            }
Exemplo n.º 18
0
            public void WhenGivenStringArrayProperty_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromDictionaryProperty(
                    StringsProperty, new Dictionary <string, string> {
                    { "t1", "v1" }, { "t2", "v2" }
                }, isSecret: false);

                CollectionAssert.AreEqual(actual, new DockerArgument[] {
                    new DockerArgument("--strings", "t1=v1", DockerArgumentQuoting.Quoted),
                    new DockerArgument("--strings", "t2=v2", DockerArgumentQuoting.Quoted),
                });
            }
            public void WhenTrue_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromBoolProperty(BoolProperty, true);

                Assert.That(actual, Is.EqualTo("--bool"));
            }
            public void WhenFalse_NullIsReturned()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromBoolProperty(BoolProperty, false);

                Assert.That(actual, Is.Null);
            }
            public void WhenGivenNull_NullIsReturned()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromStringProperty(StringProperty, null);

                Assert.That(actual, Is.Null);
            }
            public void WhenGivenInput_ConvertsProperly()
            {
                var actual = ArgumentsBuilderExtension.ConvertTimeSpan(new TimeSpan(734, 18, 4));

                Assert.That(actual, Is.EqualTo("734h18m4s"));
            }
        public void WhenNotDecorated_ReturnsNull()
        {
            var actual = ArgumentsBuilderExtension.GetAutoPropertyAttributeOrNull(StringProperty);

            Assert.That(actual, Is.Null);
        }
        public void WhenDecorated_ReturnsAutoPropertyAttribute()
        {
            var actual = ArgumentsBuilderExtension.GetAutoPropertyAttributeOrNull(DecoratedStringProperty);

            Assert.That(actual.Format, Is.EqualTo("-s {1}"));
        }
            public void WhenGivenStringProperty_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromStringProperty(StringProperty, "tubo");

                Assert.That(actual, Is.EqualTo("--string \"tubo\""));
            }
            public void WhenGivenValue_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromNullableIntProperty(NullableIntProperty, 5);

                Assert.That(actual, Is.EqualTo("--nullable-int 5"));
            }
            public void WhenGivenStringArrayProperty_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromStringArrayProperty(StringsProperty, new string[] { "tubo1", "tubo2" });

                Assert.AreEqual(actual.ToArray(), new string[] { "--strings \"tubo1\"", "--strings \"tubo2\"" });
            }
            public void WhenGivenValue_FormatsProperly()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromNullableTimeSpanProperty(NullableTimeSpanProperty, new TimeSpan(734, 18, 4));

                Assert.That(actual, Is.EqualTo("--nullable-time-span 734h18m4s"));
            }
            public void WhenGivenNull_EmptyArrayReturned()
            {
                var actual = ArgumentsBuilderExtension.GetArgumentFromDictionaryProperty(StringsProperty, null);

                Assert.That(actual, Is.Empty);
            }
 public string WhenInput_ReturnsCorrectlyFormatted(string name)
 {
     return(ArgumentsBuilderExtension.GetPropertyName(name));
 }