< Summary

Class:DCLServices.EmotesCatalog.EmoteEntityDto
Assembly:EmotesCatalog
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/EmotesCatalog/EmoteEntityDto.cs
Covered lines:0
Uncovered lines:26
Coverable lines:26
Total lines:116
Line coverage:0% (0 of 26)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:2
Method coverage:0% (0 of 2)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetContentHashByFileName(...)0%12300%
ToWearableItem(...)0%30500%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/EmotesCatalog/EmoteEntityDto.cs

#LineLine coverage
 1using DCL.Emotes;
 2using System;
 3
 4namespace DCLServices.EmotesCatalog
 5{
 6    [Serializable]
 7    public class EmoteEntityDto
 8    {
 9        [Serializable]
 10        public class ContentDto
 11        {
 12            public string file;
 13            public string hash;
 14        }
 15
 16        [Serializable]
 17        public class MetadataDto
 18        {
 19            [Serializable]
 20            public class Representation
 21            {
 22                public string[] bodyShapes;
 23                public string mainFile;
 24                public string[] contents;
 25            }
 26
 27            [Serializable]
 28            public class DataDto
 29            {
 30                public Representation[] representations;
 31                public string category;
 32                public string[] tags;
 33                public bool loop;
 34            }
 35
 36            public DataDto emoteDataADR74;
 37            public string id;
 38
 39            public i18n[] i18n;
 40            public string thumbnail;
 41
 42            public string rarity;
 43            public string description;
 44        }
 45
 46        public MetadataDto metadata;
 47        public ContentDto[] content;
 48        public string id;
 49
 50        public string GetContentHashByFileName(string fileName)
 51        {
 052            foreach (ContentDto dto in content)
 053                if (dto.file == fileName)
 054                    return dto.hash;
 55
 056            return null;
 57        }
 58
 59        public WearableItem ToWearableItem(string contentBaseUrl)
 60        {
 061            WearableItem wearable = new WearableItem();
 062            wearable.entityId = id;
 063            wearable.emoteDataV0 = null;
 64
 065            MetadataDto metadataDto = metadata;
 066            if (metadataDto == null) return wearable;
 67
 068            wearable.description = metadataDto.description;
 069            wearable.rarity = metadataDto.rarity;
 070            wearable.i18n = metadataDto.i18n;
 071            wearable.id = metadataDto.id;
 072            wearable.thumbnail = GetContentHashByFileName(metadataDto.thumbnail);
 73
 074            var data = metadataDto.emoteDataADR74;
 075            if (data == null) return wearable;
 76
 77            // todo: remove this when we refactor the WearableItem into EmoteItem
 078            wearable.emoteDataV0 = new EmoteDataV0() { loop = data.loop };
 79
 080            wearable.data = new WearableItem.Data
 81            {
 82                representations = new WearableItem.Representation[data.representations.Length],
 83                category = data.category,
 84                tags = data.tags,
 85                loop = data.loop
 86            };
 87
 088            for (var i = 0; i < data.representations.Length; i++)
 89            {
 090                MetadataDto.Representation representation = data.representations[i];
 91
 092                wearable.data.representations[i] = new WearableItem.Representation
 93                {
 94                    bodyShapes = representation.bodyShapes,
 95                    mainFile = representation.mainFile,
 96                    contents = new WearableItem.MappingPair[representation.contents.Length],
 97                };
 98
 099                for (var z = 0; z < representation.contents.Length; z++)
 100                {
 0101                    string fileName = representation.contents[z];
 0102                    string hash = GetContentHashByFileName(fileName);
 103
 0104                    wearable.data.representations[i].contents[z] = new WearableItem.MappingPair
 105                    {
 106                        url = $"{contentBaseUrl}/{hash}",
 107                        hash = hash,
 108                        key = fileName,
 109                    };
 110                }
 111            }
 112
 0113            return wearable;
 114        }
 115    }
 116}