public void LoadRavnicaAllegienceBooster()
        {
            _logger.DebugFormat("Loading RNA booster.");
            if (!_isInitialized)
            {
                _logger.DebugFormat($"{typeof(MTGCardProvider)} is not yet initialized.");
                SetService setService = new SetService();
                var        result     = setService.GenerateBooster("RNA");
                _logger.DebugFormat("Response received from API.");

                if (result.IsSuccess)
                {
                    _logger.DebugFormat($"{nameof(result)} returned success.");
                    _booster       = result.Value;
                    _isInitialized = true;
                    _logger.DebugFormat($"{typeof(MTGCardProvider)} is initialized.");
                }
            }
            else
            {
                _logger.DebugFormat($"{typeof(MTGCardProvider)} is already initialized.");
            }
        }
        public void GenerateBoosterTest()
        {
            var cards = new List <CardDto>()
            {
                new CardDto()
                {
                    Artist       = "artist1",
                    Border       = "border1",
                    Cmc          = 111,
                    Colors       = new string[] { "blue", "pink" },
                    Flavor       = "flavor1",
                    ForeignNames = new ForeignNameDto[] { new ForeignNameDto()
                                                          {
                                                              Language = "english", MultiverseId = 222, Name = "name2"
                                                          } },
                    Hand       = 222,
                    Id         = "12345",
                    ImageUrl   = new System.Uri("http://fake/url"),
                    Layout     = "layout1",
                    Legalities = new LegalityDto[] { new LegalityDto()
                                                     {
                                                         Format = "format2", LegalityName = "legality name 2"
                                                     } },
                    Life         = 333,
                    Loyalty      = "loyalty",
                    ManaCost     = "500",
                    MultiverseId = 444,
                    Name         = "name1",
                    Names        = new string[] { "name2", "name3" },
                    Number       = "600",
                    OriginalText = "original text",
                    OriginalType = "original type",
                    Power        = "9000",
                    Printings    = new string[] { "printing1", "printing2" },
                    Rarity       = "rare",
                    ReleaseDate  = "2010, 1, 1",
                    Reserved     = true,
                    Rulings      = new RulingDto[] { new RulingDto()
                                                     {
                                                         Date = "2010, 2, 2", Text = "text2"
                                                     } },
                    Set         = "set1",
                    SetName     = "set name 1",
                    Source      = "source",
                    Starter     = true,
                    SubTypes    = new string[] { "subtype1", "subtype2" },
                    SuperTypes  = new string[] { "supertype1", "supertype2" },
                    Text        = "text3",
                    Timeshifted = false,
                    Toughness   = "tough",
                    Type        = "type2",
                    Types       = new string[] { "type1", "type2" },
                    Variations  = new int[] { 1, 2, 3 },
                    Watermark   = "watermark"
                },
                new CardDto()
                {
                    Artist       = "artist1",
                    Border       = "border1",
                    Cmc          = 111,
                    Colors       = new string[] { "blue", "pink" },
                    Flavor       = "flavor1",
                    ForeignNames = new ForeignNameDto[] { new ForeignNameDto()
                                                          {
                                                              Language = "english", MultiverseId = 222, Name = "name2"
                                                          } },
                    Hand       = 222,
                    Id         = "12345",
                    ImageUrl   = new System.Uri("http://fake/url"),
                    Layout     = "layout1",
                    Legalities = new LegalityDto[] { new LegalityDto()
                                                     {
                                                         Format = "format2", LegalityName = "legality name 2"
                                                     } },
                    Life         = 333,
                    Loyalty      = "loyalty",
                    ManaCost     = "500",
                    MultiverseId = 444,
                    Name         = "name1",
                    Names        = new string[] { "name2", "name3" },
                    Number       = "600",
                    OriginalText = "original text",
                    OriginalType = "original type",
                    Power        = "9000",
                    Printings    = new string[] { "printing1", "printing2" },
                    Rarity       = "rare",
                    ReleaseDate  = "2010, 1, 1",
                    Reserved     = true,
                    Rulings      = new RulingDto[] { new RulingDto()
                                                     {
                                                         Date = "2010, 2, 2", Text = "text2"
                                                     } },
                    Set         = "set1",
                    SetName     = "set name 1",
                    Source      = "source",
                    Starter     = true,
                    SubTypes    = new string[] { "subtype1", "subtype2" },
                    SuperTypes  = new string[] { "supertype1", "supertype2" },
                    Text        = "text3",
                    Timeshifted = false,
                    Toughness   = "tough",
                    Type        = "type2",
                    Types       = new string[] { "type1", "type2" },
                    Variations  = new int[] { 1, 2, 3 },
                    Watermark   = "watermark"
                }
            };

            // Test the All method.
            var moqAdapter = new Mock <IMtgApiServiceAdapter>();

            moqAdapter
            .SetupSequence(x => x.WebGetAsync <RootCardListDto>(It.IsAny <Uri>()))
            .Throws <ArgumentNullException>()
            .Throws(new MtgApiException <BadRequestException>("bad request"))
            .Throws(new MtgApiException <ForbiddenException>("forbidden"))
            .Throws(new MtgApiException <InternalServerErrorException>("server error"))
            .Throws(new MtgApiException <NotFoundException>("not found"))
            .Throws(new MtgApiException <ServiceUnavailableException>("unavailable"))
            .Throws <Exception>()
            .ReturnsAsync(new RootCardListDto()
            {
                Cards = cards
            });

            var service = new SetService(moqAdapter.Object, ApiVersion.V1_0, false);

            var result = service.GenerateBooster("ktk");

            Assert.False(result.IsSuccess);
            Assert.Equal("Value cannot be null.", result.Exception.Message);

            result = service.GenerateBooster("ktk");
            Assert.False(result.IsSuccess);
            Assert.Equal("bad request", result.Exception.Message);

            result = service.GenerateBooster("ktk");
            Assert.False(result.IsSuccess);
            Assert.Equal("forbidden", result.Exception.Message);

            result = service.GenerateBooster("ktk");
            Assert.False(result.IsSuccess);
            Assert.Equal("server error", result.Exception.Message);

            result = service.GenerateBooster("ktk");
            Assert.False(result.IsSuccess);
            Assert.Equal("not found", result.Exception.Message);

            result = service.GenerateBooster("ktk");
            Assert.False(result.IsSuccess);
            Assert.Equal("unavailable", result.Exception.Message);

            result = service.GenerateBooster("ktk");
            Assert.False(result.IsSuccess);
            Assert.IsType <Exception>(result.Exception);

            result = service.GenerateBooster("ktk");
            Assert.True(result.IsSuccess);
            Assert.Null(result.Exception);
            Assert.NotNull(result.Value);
        }