Пример #1
0
        public static void ToString1()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("the builder is empty", () =>
            {
                Act(() =>
                {
                    builder.ToString();
                    builder.ToString();
                    result = builder.ToString();
                });

                Should("provide an empty string", () =>
                {
                    Assert.That(result, Is.Empty);
                });

                And("a value is added", () =>
                {
                    Act(() =>
                    {
                        builder.AddValue("value1");

                        builder.ToString();
                        builder.ToString();
                        result = builder.ToString();
                    });

                    Should("provide the added value", () =>
                    {
                        Assert.That(result, Is.EqualTo("value1"));
                    });
                });
            });
        }
Пример #2
0
        public static void OperatorString()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            When("the builder is null", () =>
            {
                Act(() =>
                {
                    builder = null;

                    result = builder;
                });

                Should("provide null", () =>
                {
                    Assert.That(result, Is.Null);
                });

                And("the builder is not null and a value is added", () =>
                {
                    Act(() =>
                    {
                        builder = ArgsBuilder.By("-", "=");
                        builder.AddValue("value1");

                        result = builder;
                    });

                    Should("provide the added value", () =>
                    {
                        Assert.That(result, Is.EqualTo("value1"));
                    });
                });
            });
        }
Пример #3
0
        public static void AddValue()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("added a value", () =>
            {
                var condition = true;
                string value  = null;

                Act(() =>
                {
                    result = builder.AddValue(value, condition);
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    And("the value is provided", () =>
                    {
                        value = "value1";

                        Should("provide the provided value", () =>
                        {
                            Assert.That(result, Is.EqualTo(value));
                        });
                    });

                    And("the value is an empty string", () =>
                    {
                        value = string.Empty;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });

                    And("the value is null", () =>
                    {
                        value = null;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }