Exemplo n.º 1
0
        public void Serialize_WorksForKeysAndProperties()
        {
            // Arrange
            Args args = new MockArgs
            {
                ["boolean"] = true,
                ["String"]  = "somevalue",
                ["int"]     = 15,

                Enumerable = new[] { "1", "a" },
                Object     = new MockArgs.MockObject {
                    Int = 1, String = "string"
                },
                Argument = false
            };
            // Act
            var result = args.Serialize();

            // Assert
            Assert.Contains("-argument:\"False\"", result);
            Assert.Contains("-enumerable:\"1\" -enumerable:\"a\"", result);
            Assert.Contains("-object:\"Int=1;String=string;\"", result);
            Assert.Contains("-boolean:\"True\"", result);
            Assert.Contains("-String:\"somevalue\"", result);
            Assert.Contains("-int:\"15\"", result);
        }
Exemplo n.º 2
0
        public void SerializeArgument_WorksForEnumerableObjectProperty()
        {
            // Arrange
            var args = new MockArgs();

            args.EnumerableObject = new MockArgs.MockObject[]
            {
                new MockArgs.MockObject
                {
                    Int    = 1,
                    String = "a",
                    Object = null
                },
                new MockArgs.MockObject
                {
                    Int    = 2,
                    String = "",
                    Object = false
                },
            };
            // Act
            var result = args.SerializeArgument(nameof(MockArgs.EnumerableObject));

            // Assert
            Assert.Equal("-enumerable_object:\"Int=1;String=a;\" -enumerable_object:\"Int=2;String=;Object=False;\"", result);
        }
Exemplo n.º 3
0
        public void SerializeArgument_WorksForEnumerableProperty()
        {
            // Arrange
            var args = new MockArgs();

            args.Enumerable = new object[] { "a", 1, true };
            // Act
            var result = args.SerializeArgument(nameof(MockArgs.Enumerable));

            // Assert
            Assert.Equal("-enumerable:\"a\" -enumerable:\"1\" -enumerable:\"True\"", result);
        }
Exemplo n.º 4
0
        public void SerializeArgument_WorksForProperty_SetByKey_GetProperty()
        {
            // Arrange
            var args = new MockArgs();

            args["argument"] = "value";
            // Act
            var result = args.SerializeArgument(nameof(MockArgs.Argument));

            // Assert
            Assert.Equal("-argument:\"value\"", result);
        }
Exemplo n.º 5
0
        public void SerializeArgument_WorksForObjectProperty()
        {
            // Arrange
            var args = new MockArgs();

            args.Object = new MockArgs.MockObject
            {
                Int    = 1,
                String = "a",
                Object = null
            };
            // Act
            var result = args.SerializeArgument(nameof(MockArgs.Object));

            // Assert
            Assert.Equal("-object:\"Int=1;String=a;\"", result);
        }
Exemplo n.º 6
0
        public void Enumerator_WorksForKeysAndProperties()
        {
            // Arrange
            Args args = new MockArgs
            {
                ["String"] = "somevalue",
                ["int"]    = 15,

                Argument = false
            };
            // Act
            var result = args.Select(x => x).ToList();

            // Asert
            Assert.Contains(NewPair("String", "somevalue"), result);
            Assert.Contains(NewPair("int", 15), result);
            Assert.Contains(NewPair("argument", false), result);
        }
Exemplo n.º 7
0
        public void ToListExtension_Works()
        {
            // Arrange
            Args args = new MockArgs
            {
                ["String"] = "somevalue",
                ["int"]    = 15,

                Argument = false
            };
            // Act
            var result = args.ToList();

            // Asert
            Assert.Contains(NewPair("String", "somevalue"), result);
            Assert.Contains(NewPair("int", 15), result);
            Assert.Contains(NewPair("argument", false), result);
        }
Exemplo n.º 8
0
        public void Serialize_WorksForProperties()
        {
            // Arrange
            Args args = new MockArgs
            {
                Enumerable = new[] { "1", "a" },
                Object     = new MockArgs.MockObject {
                    Int = 1, String = "string"
                },
                Argument = false
            };
            // Act
            var result = args.Serialize();

            // Assert
            Assert.Contains("-argument:\"False\"", result);
            Assert.Contains("-enumerable:\"1\" -enumerable:\"a\"", result);
            Assert.Contains("-object:\"Int=1;String=string;\"", result);
        }