示例#1
0
        public async Task CreateSeason_WhenCalled_CreateNewSeason()
        {
            const int    id   = 1;
            const string name = "2018/2019";

            var seasonCreateDto = new SeasonCreateDto
            {
                Name = name
            };

            var expectedSeason = new Season
            {
                Id   = id,
                Name = name
            };

            _seasonService.Setup(s => s.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(expectedSeason);

            var result = await _seasonsController.CreateSeason(seasonCreateDto);

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

            _seasonService.Verify(s => s.CreateAsync(It.IsAny <Season>()), Times.Once);

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