public async Task Given_A_YugiohBanlist_Should_Invoke_FormatByAcronym_Method_Once()
        {
            // Arrange
            const int expected      = 1;
            var       yugiohBanlist = new YugiohBanlist();

            _formatRepository.FormatByAcronym(Arg.Any <string>()).Returns(new Format());
            _banlistRepository.Add(Arg.Any <Banlist>()).Returns(new Banlist());

            // Act
            await _sut.Add(yugiohBanlist);

            // Assert
            await _formatRepository.Received(expected).FormatByAcronym(Arg.Any <string>());
        }
Esempio n. 2
0
        public async Task Given_A_YugiohBanlist_Should_Invoke_GetBanlistById_Method_Once()
        {
            // Arrange
            const int expected      = 1;
            var       yugiohBanlist = new YugiohBanlist {
                BanlistType = BanlistType.Tcg
            };

            _formatRepository.FormatByAcronym(Arg.Any <string>()).Returns(new Format());
            _banlistRepository.Update(Arg.Any <Banlist>()).Returns(new Banlist());
            _banlistRepository.GetBanlistById(Arg.Any <int>()).Returns(new Banlist());

            // Act
            await _sut.Update(yugiohBanlist);

            // Assert
            await _banlistRepository.Received(expected).GetBanlistById(Arg.Any <int>());
        }
Esempio n. 3
0
        public async Task <Banlist> Add(YugiohBanlist yugiohBanlist)
        {
            var format = await _formatRepository.FormatByAcronym(yugiohBanlist.BanlistType.ToString());

            if (format == null)
            {
                throw new ArgumentException($"Format with acronym '{yugiohBanlist.BanlistType.ToString()}' not found.");
            }

            var newBanlist = _mapper.Map <Banlist>(yugiohBanlist);

            newBanlist.FormatId = format.Id;

            newBanlist = await _banlistRepository.Add(newBanlist);

            newBanlist.BanlistCard = await _banlistCardService.Update(newBanlist.Id, yugiohBanlist.Sections);

            return(newBanlist);
        }