public void SerializeInput_Test()
        {
            var input = new Input
            {
                K = 10,
                Sums = new[] {1.01m, 2.02m, 2},
                Muls = new[] {1, 4}
            };

            var exceptedObj = "{\"K\":10,\"Sums\":[1.01,2.02,2.0],\"Muls\":[1,4]}";
            var jsonBaseSerializer = new JsonBaseSerializer<Input>();
            var jsonOutput = jsonBaseSerializer.Serialize(input);
            Assert.AreEqual(exceptedObj, jsonOutput);
        }
        public void SerializeInput_Test()
        {
            var input = new Input
            {
                K = 10,
                Sums = new[] { 1.01m, 2.02m },
                Muls = new[] { 1, 4 }
            };

            var exceptedObj = "<Input><K>10</K><Sums><decimal>1.01</decimal><decimal>2.02</decimal></Sums><Muls><int>1</int><int>4</int></Muls></Input>";
            var xmlSerializer = new XmlBaseSerializer<Input>();
            var xmlObj = xmlSerializer.Serialize(input);
            Assert.AreEqual(exceptedObj, xmlObj);
        }
Пример #3
0
        public void ConvertInputToOutput_Test()
        {
            var input = new Input
            {
                K = 10,
                Sums = new[] { 1.01m, 2.02m },
                Muls = new[] { 1, 4 }
            };

            var exceptedOutput = new Output
            {
                SumResult = 30.30m,
                MulResult = 4,
                SortedInputs = new[] { 1m, 1.01m, 2.02m, 4m }
            };

            var output = _ioAdapter.Convert(input);
            Assert.AreEqual(exceptedOutput, output);
        }