Пример #1
0
        public void TestApiPostStringLab6Data()
        {
            const string jsonString = @"{
                ""X0"": [ 10.005, 3.033, 6.831, 1.985, 5.093, 4.057, 0.991 ],
                ""A"": [
                [ 1, -1, -1, 0, 0, 0, 0 ],
                [ 0, 0, 1, -1, -1, 0, 0 ],
                [ 0, 0, 0, 0, 1, -1, -1 ]
                ],
                ""B"": [ 0, 0, 0 ],
                ""Measurability"": [ 1, 1, 1, 1, 1, 1, 1 ],
                ""Tolerance"": [ 0.2, 0.121, 0.683, 0.04, 0.102, 0.081, 0.02 ],
                ""LowerMetrologic"": [ 0, 0, 0, 0, 0, 0, 0 ],
                ""UpperMetrologic"": [ 10000, 10000, 10000, 10000, 10000, 10000, 10000 ]
            }";

            var expected = new[] { 10.05561, 3.01447, 7.04114, 1.98225, 5.05888, 4.06726, 0.99163 };

            var controller = new BalanceController();
            var result     = controller.PostStringAsync(jsonString).Result;
            var resultData = result.Data as OutputData;

            Assert.Equal("result", result.Type);

            for (var i = 0; i < resultData?.X.Length; i++)
            {
                Assert.Equal(expected[i], resultData.X[i], 3);
            }
        }
Пример #2
0
        public void TestApiPostStringEmpty()
        {
            var controller = new BalanceController();
            var result     = controller.PostStringAsync("").Result;

            Assert.Equal("error", result.Type);
        }
Пример #3
0
        public void TestApiPostStringIncorrect()
        {
            const string jsonString = @"{
                ""X0"": [ 10.005, 3.033, 6.831, 1.985, 5.093, 4.057, 0.991 ],
                ""A"": [
                [ 1, -1, -1, 0, 0, 0, 0 ],
                [ 0, 0, 1, -1, -1, 0, 0 ],
                [ 0, 0, 0, 0, 1, -1, -1 ]
                ],
                ""B"": [ 0, 0, 0 ],
                ""Measurability"": [ 1, 1, 1, 1, 1, 1, 1 ],
                ""Tolerance"": [ 0.2, 0.121, 0.683, 0.04, 0.102, 0.081, 0.02 ],
                ""LowerMetrologic"": [ 0, 0, 0, 0, 0, 0, 0 ]
            }";

            var controller = new BalanceController();
            var result     = controller.PostStringAsync(jsonString).Result;

            Assert.Equal("error", result.Type);
        }