Esempio n. 1
0
        public async Task GetById_HasData_ReturnSuccess()
        {
            _context.Functions.AddRange(new List <Function>()
            {
                new Function()
                {
                    Id        = "GetById_HasData_ReturnSuccess",
                    ParentId  = null,
                    Name      = "GetById_HasData_ReturnSuccess",
                    SortOrder = 1,
                    Url       = "/GetById_HasData_ReturnSuccess"
                }
            });
            await _context.SaveChangesAsync();

            var functionsController = new FunctionsController(_context);
            var result = await functionsController.GetById("GetById_HasData_ReturnSuccess");

            var okResult = result as OkObjectResult;

            Assert.NotNull(okResult);

            var userVm = okResult.Value as FunctionVm;

            Assert.Equal("GetById_HasData_ReturnSuccess", userVm.Id);
        }
        public async Task GetById_HasData_ReturnSuccess()
        {
            _localizer = MockLocalizer();
            _context.Functions.AddRange(new List <Function>()
            {
                new Function()
                {
                    Id        = "GetById_HasData_ReturnSuccess",
                    ParentId  = null,
                    NameTemp  = "GetById_HasData_ReturnSuccess",
                    SortOrder = 1,
                    Url       = "/GetById_HasData_ReturnSuccess"
                }
            });
            await _context.SaveChangesAsync();

            var controller = new FunctionsController(_context, _mockLogger.Object, _mapper, _localizer, _returnString);
            var result     = await controller.GetById("GetById_HasData_ReturnSuccess");

            var okResult = result as OkObjectResult;

            Assert.NotNull(okResult);

            var userVm = okResult.Value as FunctionVm;

            Assert.Equal("GetById_HasData_ReturnSuccess", userVm.Id);
        }