Пример #1
0
        public async Task GetGuidsShouldExecuteRepositoryGetGuids()
        {
            //Arrange
            List <Text> arr = new List <Text>();

            for (int i = 0; i < 5; i++)
            {
                arr.Add(new Text()
                {
                    Id        = Guid.NewGuid(),
                    TextValue = "Текст" + i
                });
            }

            _textRepository.Setup(x => x.GetGuidsFromDT(It.IsAny <string>())).ReturnsAsync(arr);
            var controller = new TextController(_logger, _textService);

            //Act
            var actionResult = await controller.GetGuids("20241231235959");

            //Assert
            var result = actionResult.Result as OkObjectResult;
            var guids  = result.Value as List <string>;
            var json   = JsonConvert.SerializeObject(result.Value);

            //var values = JsonConvert.DeserializeObject<string>(json);


            Assert.NotNull(result);
            Assert.NotNull(guids);
            for (int i = 0; i < guids.Count; i++)
            {
                Assert.Equal(Guid.Parse(guids[i]), arr[i].Id);
            }
            _textRepository.Verify(x => x.GetGuidsFromDT(It.IsAny <string>()));
        }