Ejemplo n.º 1
0
        public async Task ListPermissionsAsync_WithNoInputs_ReturnsList()
        {
            // Arrange
            var permissionService = Substitute.For <IPermissionService>();

            var inList = new List <Permission>();

            inList.Add(new Permission {
                Name = "Test Permissions 1", Uuid = Guid.NewGuid()
            });
            inList.Add(new Permission {
                Name = "Test Permissions 2", Uuid = Guid.NewGuid()
            });
            inList.Add(new Permission {
                Name = "Test Permissions 3", Uuid = Guid.NewGuid()
            });

            permissionService.GetListAsync().Returns(inList);

            var controller = new PermissionsController(permissionService);

            // Act
            IActionResult actionResult = await controller.ListPermissionsAsync(0, 50, string.Empty, null);

            // Assert
            var okResult = actionResult as OkObjectResult;

            Assert.NotNull(okResult);

            var outList = okResult.Value as List <Permission>;

            Assert.NotNull(outList);

            for (var i = 0; i < outList.Count; i++)
            {
                Assert.Equal(outList[i].Uuid, inList[i].Uuid);
                Assert.Equal(outList[i].Name, inList[i].Name);
            }
        }