예제 #1
0
        public void GetStructsWithoutFileUploadTest()
        {
            var analyzerController = new AnalyzerController(mockHttpContextAccessor.Object);

            var result = analyzerController.GetStructs();

            var objectResult = Assert.IsType <BadRequestObjectResult>(result);
            var model        = Assert.IsAssignableFrom <string>(objectResult.Value);

            Assert.Equal("Kérem töltsön fel először fájlt!", model);
        }
예제 #2
0
        public void GetStructsTest(int no)
        {
            var analyzerController = new AnalyzerController(mockHttpContextAccessor.Object);
            var file = new FileData {
                Name = "Valami", Content = System.IO.File.ReadAllText($@"..\..\..\..\AngularApp\Files\demo{no}.txt")
            };

            var value = Encoding.ASCII.GetBytes(JsonSerializer.Serialize(file));

            mockSession.Setup(_ => _.TryGetValue(Key.File.ToString("g"), out value)).Returns(true);
            var result = analyzerController.GetStructs();

            var objectResult = Assert.IsType <OkObjectResult>(result);
            var model        = Assert.IsAssignableFrom <List <Struct> >(objectResult.Value);
            var structs      = Analyzer.GetStructs(file.Content);

            for (var i = 0; i < structs.Count; ++i)
            {
                CompareStuct(structs[i], model[i]);
            }
        }