コード例 #1
0
        public async Task CreateManager_WhenCalled_CreateNewManager()
        {
            const int    id   = 1;
            const string name = "Josep Guardiola";

            var managerCreateDto = new ManagerCreateDto
            {
                Name = name
            };

            var expectedManager = new Manager
            {
                Id   = id,
                Name = name
            };

            _managerService.Setup(m => m.GetDetailByIdAsync(It.IsAny <int>())).ReturnsAsync(expectedManager);

            var result = await _managersController.CreateManager(managerCreateDto);

            var okObjectResult      = result as OkObjectResult;
            var okObjectResultValue = okObjectResult.Value as ManagerDetailDto;

            _managerService.Verify(m => m.CreateAsync(It.IsAny <Manager>()), Times.Once);

            Assert.That(result, Is.TypeOf <OkObjectResult>());
            Assert.That(okObjectResultValue.Name, Is.EqualTo(name));
        }