Exemple #1
0
        public async Task DbError_ThrowException()
        {
            _repository.Setup(x => x.GetByKeyAsync(It.IsAny <short>(), It.IsAny <string>()))
            .ThrowsAsync(new DataException());

            var service = new SeasonConfigService(null, _repository.Object, _mapper);

            Assert.ThrowsAsync <DataException>(async() => await service.GetConfig(Year, Season));

            _repository.Verify(x => x.GetByKeyAsync(It.IsAny <short>(), It.IsAny <string>()), Times.Once);
        }
        public void DbError_ThrowException()
        {
            _repository.Setup(x => x.GetYearConfig(It.IsAny <short>()))
            .ThrowsAsync(new DataException());

            var service = new SeasonConfigService(_repository.Object, null, _mapper);

            Assert.ThrowsAsync <DataException>(async() => await service.GetConfig(Year));

            _repository.Verify(x => x.GetYearConfig(It.IsAny <short>()), Times.Once);
        }
Exemple #3
0
        public async Task Ok_Success()
        {
            _repository.Setup(x => x.GetByKeyAsync(It.IsAny <short>(), It.IsAny <string>())).ReturnsAsync(MockedConfig());

            var service = new SeasonConfigService(null, _repository.Object, _mapper);
            var result  = await service.GetConfig(Year, Season);

            Assert.NotNull(result);
            Assert.IsInstanceOf <SeasonConfig>(result);
            Assert.NotNull(result.Name);
            Assert.AreEqual(13, result.RoundsCount);

            _repository.Verify(x => x.GetByKeyAsync(It.IsAny <short>(), It.IsAny <string>()), Times.Once);
        }
        public async Task Ok_Success()
        {
            _repository.Setup(x => x.GetYearConfig(It.IsAny <short>())).ReturnsAsync(MockedConfig());

            var service = new SeasonConfigService(_repository.Object, null, _mapper);
            var result  = await service.GetConfig(Year);

            Assert.NotNull(result);
            Assert.IsInstanceOf <ChampionshipConfig>(result);
            Assert.NotNull(result.Name);
            Assert.True(result.Seasons.Any());

            _repository.Verify(x => x.GetYearConfig(It.IsAny <short>()), Times.Once);
        }