Exemplo n.º 1
0
        public async Task CreateProjectTest()
        {
            _mediator.Setup(m => m.Send(It.IsAny <CreateProjectCommand>(), new System.Threading.CancellationToken()))
            .Returns(Task.FromResult(new Core.ApiResponse.ApiResult
            {
                Code = Core.Enums.Code.Ok
            }));

            _authorizationService.Setup(g => g.GetUser())
            .Returns(new Core.DataStructure.ControllerUser
            {
                UserName = "******",
                UserId   = 1234
            });

            var command = new CreateProjectCommand
            {
                ProjectName = "测试标题",
                Desc        = "测试描述",
                Platform    = "github"
            };

            var controller = new ProjectController(_mediator.Object, _log.Object, _authorizationService.Object, _projectQueries.Object);
            var result     = await controller.CreateProjectAsync(command);

            Assert.NotNull(result);
            Assert.Equal(Code.Ok, result.Code);
        }