Ejemplo n.º 1
0
        public async Task <SimcProfile> GenerateProfileAsync(List <string> profileString)
        {
            if (profileString == null || profileString.Count == 0)
            {
                throw new ArgumentNullException(nameof(profileString), "profile string must contain valid entries");
            }

            // Process the incoming profile string
            var parsedProfile = await Task <SimcParsedProfile> .Factory.StartNew(
                () => _simcParserService.ParseProfileAsync(profileString));

            if (parsedProfile == null)
            {
                throw new ArgumentOutOfRangeException(nameof(profileString), "profileString provided was invalid or produced no results");
            }

            // Build up the basics of the new object
            var newProfile = new SimcProfile
            {
                ParsedProfile = parsedProfile
            };

            // Now build up the items
            foreach (var item in newProfile.ParsedProfile.Items)
            {
                var newItem = await _simcItemCreationService.CreateItemAsync(item);

                newProfile.GeneratedItems.Add(newItem);

                newItem.Equipped = item.Equipped;
            }

            // Populate the spell Ids of any conduits set
            foreach (var conduit in newProfile.ParsedProfile.Conduits)
            {
                conduit.SpellId = await _simcSpellCreationService
                                  .GetSpellIdFromConduitIdAsync((uint)conduit.ConduitId);
            }

            // and populate the spell Ids of any conduits set)
            foreach (var soulbind in newProfile.ParsedProfile.Soulbinds)
            {
                foreach (var conduit in soulbind.SocketedConduits)
                {
                    conduit.SpellId = await _simcSpellCreationService
                                      .GetSpellIdFromConduitIdAsync((uint)conduit.ConduitId);
                }
            }

            return(newProfile);
        }
Ejemplo n.º 2
0
        public async Task ICS_Parses_Entire_Data_file()
        {
            // Arrange

            // Load a data file
            var testFile         = @"RawData" + Path.DirectorySeparatorChar + "Alfouhk.simc";
            var testFileContents = await File.ReadAllLinesAsync(testFile);

            var testFileString = new List <string>(testFileContents);

            // Create a new item creation service
            var simcParser    = new SimcParserService(_loggerFactory.CreateLogger <SimcParserService>());
            var parsedProfile = simcParser.ParseProfileAsync(testFileString);

            // Act
            var items = new List <SimcItem>();

            foreach (var parsedItemData in parsedProfile.Items)
            {
                var item = await _ics.CreateItemAsync(parsedItemData);

                items.Add(item);
            }

            // Assert
            Assert.IsNotNull(items);
            Assert.NotZero(items.Count);
        }