Ejemplo n.º 1
0
        public async Task RemoveSpecialPortraits_PlayersHave_Success()
        {
            var personalSettingsRepository = new PersonalSettingsRepository(MongoClient);
            var playerRepo             = new PlayerRepository(MongoClient);
            var portraitRepo           = new PortraitRepository(MongoClient);
            var portraitCommandHandler = new PortraitCommandHandler(personalSettingsRepository, playerRepo, portraitRepo);

            int[] validPortraits = { 5, 50, 500, 5000 };
            await portraitCommandHandler.AddPortraitDefinition(CreatePortraitsDefinitionCommand(validPortraits.ToList(), new List <string>()));

            string[] playerTags = { "cepheid#1467" };

            var portraitIds = new List <int>();

            portraitIds.Add(5);
            portraitIds.Add(50);
            portraitIds.Add(500);
            portraitIds.Add(5000);

            var upsertCommand = new PortraitsCommand();

            upsertCommand.Portraits = portraitIds;
            upsertCommand.BnetTags  = playerTags.AsEnumerable().ToList();
            upsertCommand.Tooltip   = "description";

            var listOfSettings = new List <PersonalSetting>();

            foreach (var tag in playerTags)
            {
                listOfSettings.Add(new PersonalSetting(tag));
            }
            await personalSettingsRepository.SaveMany(listOfSettings);

            await portraitCommandHandler.UpsertSpecialPortraits(upsertCommand);

            var deleteCommand = new PortraitsCommand();

            deleteCommand.Portraits = new List <int>();
            deleteCommand.Portraits.Add(500);
            deleteCommand.BnetTags = playerTags.AsEnumerable().ToList();
            deleteCommand.Tooltip  = "Multiple Tags Portrait Test Tooltip";

            await portraitCommandHandler.DeleteSpecialPortraits(deleteCommand);

            var settings = await personalSettingsRepository.LoadMany(playerTags);

            Assert.AreEqual(3, settings.First().SpecialPictures.Count());
            CollectionAssert.IsEmpty(settings
                                     .FindAll(x => x.SpecialPictures
                                              .AsEnumerable()
                                              .ToList()
                                              .FindAll(x => x.PictureId == 500)
                                              .Count() > 0));
        }
Ejemplo n.º 2
0
        public async Task RemoveSpecialPortrait_PlayerDoesNotHave_NoExceptionThrown()
        {
            var personalSettingsRepository = new PersonalSettingsRepository(MongoClient);
            var playerRepo             = new PlayerRepository(MongoClient);
            var portraitRepo           = new PortraitRepository(MongoClient);
            var portraitCommandHandler = new PortraitCommandHandler(personalSettingsRepository, playerRepo, portraitRepo);

            int[] validPortraits = { 5, 50, 500, 5000 };
            await portraitCommandHandler.AddPortraitDefinition(CreatePortraitsDefinitionCommand(validPortraits.ToList(), new List <string>()));

            string[] playerTags = { "cepheid#1467" };

            var portraitIds = new List <int>();

            portraitIds.Add(5);
            portraitIds.Add(50);
            portraitIds.Add(500);
            portraitIds.Add(5000);

            var upsertCommand = new PortraitsCommand();

            upsertCommand.Portraits = portraitIds;
            upsertCommand.BnetTags  = playerTags.AsEnumerable().ToList();
            upsertCommand.Tooltip   = "description";

            var listOfSettings = new List <PersonalSetting>();

            foreach (var tag in playerTags)
            {
                listOfSettings.Add(new PersonalSetting(tag));
            }
            await personalSettingsRepository.SaveMany(listOfSettings);

            await portraitCommandHandler.UpsertSpecialPortraits(upsertCommand);

            var deleteCommand = new PortraitsCommand();

            deleteCommand.Portraits = new List <int>();
            deleteCommand.Portraits.Add(100);
            deleteCommand.BnetTags = playerTags.AsEnumerable().ToList();
            deleteCommand.Tooltip  = "this text is irrelevant";

            await portraitCommandHandler.DeleteSpecialPortraits(deleteCommand);

            var settings = await personalSettingsRepository.Load(playerTags[0]);

            Assert.AreEqual(4, settings.SpecialPictures.Count());
        }