Пример #1
0
        public async Task Grouping_MultipleVersions_MultipleMethods()
        {
            // arrange
            var service = SetupForGetEncounterDetails();

            var conditionValues = PokeApiHelpers.ConditionValues(0).ToList();

            var version1    = PokeApiHelpers.NamedResourceNavigation <Version>("version1", "url1");
            var maxChance1  = 1;
            var method1     = PokeApiHelpers.NamedResourceNavigation <EncounterMethod>("method1", "url1");
            var encounters1 = PokeApiHelpers.Encounters(2, conditionValues, method1);
            var ved1        = new VersionEncounterDetail
            {
                Version          = version1,
                MaxChance        = maxChance1,
                EncounterDetails = encounters1.ToList()
            };

            var maxChance2  = 2;
            var method2     = PokeApiHelpers.NamedResourceNavigation <EncounterMethod>("method2", "url2");
            var encounters2 = PokeApiHelpers.Encounters(3, conditionValues, method2);
            var ved2        = new VersionEncounterDetail
            {
                Version          = version1,
                MaxChance        = maxChance2,
                EncounterDetails = encounters2.ToList()
            };

            var version2 = PokeApiHelpers.NamedResourceNavigation <Version>("version2", "url2");
            var ved3     = new VersionEncounterDetail
            {
                Version          = version2,
                MaxChance        = maxChance1,
                EncounterDetails = encounters1.ToList()
            };

            var ved4 = new VersionEncounterDetail
            {
                Version          = version2,
                MaxChance        = maxChance2,
                EncounterDetails = encounters2.ToList()
            };

            var versionEncounterDetails = new[] { ved1, ved2, ved3, ved4 };

            // act
            var entries = await service.GetEncounterDetails(versionEncounterDetails);

            var entryList = entries.ToList();

            // assert
            Assert.That(entryList.Count, Is.EqualTo(2));

            foreach (var entry in entryList)
            {
                Assert.That(entry.Data.Length, Is.EqualTo(2));
            }
        }
Пример #2
0
        public async Task Grouping_OneVersion_MultipleEncounters_SameMethod_DifferentConditions()
        {
            // arrange
            var service = SetupForGetEncounterDetails();

            var method = PokeApiHelpers.NamedResourceNavigation <EncounterMethod>("method1", "url1");

            var conditionValues1 = PokeApiHelpers.ConditionValues(1).ToList();
            var encounter1       = PokeApiHelpers.Encounter(conditionValues: conditionValues1, method: method);

            var conditionValues2 = PokeApiHelpers.ConditionValues(2).ToList();
            var encounter2       = PokeApiHelpers.Encounter(conditionValues: conditionValues2, method: method);

            var ved1 = new VersionEncounterDetail
            {
                Version          = PokeApiHelpers.NamedResourceNavigation <Version>(),
                MaxChance        = 1,
                EncounterDetails = new[] { encounter1, encounter2 }.ToList()
            };

            var versionEncounterDetails = new[] { ved1 };

            // act
            var entries = await service.GetEncounterDetails(versionEncounterDetails);

            var entryList = entries.ToList();

            // assert

            // should be only one version
            Assert.That(entryList.Count, Is.EqualTo(1));
            var entry = entryList[0];

            // should only be one method
            Assert.That(entry.Data.Length, Is.EqualTo(1));
            var methodDetail = entry.Data[0];

            // should be two condition values details
            Assert.That(methodDetail.ConditionValuesDetails.Count, Is.EqualTo(2));
        }