Exemplo n.º 1
0
 private static void AddSocketGroups(ItemSockets itemSockets, string socketsString)
 {
     socketsString.Split(socketGroupSeparators, StringSplitOptions.RemoveEmptyEntries)
     .Select(GetSocketGroup)
     .ToList()
     .ForEach(itemSockets.SocketGroups.Add);
 }
        public void ParseShouldSetSocketsOnItem()
        {
            string[] itemStringLines = this.itemStringBuilder
                                       .BuildLines();

            ItemSockets expected = new ItemSockets
            {
                SocketGroups =
                {
                    new SocketGroup    {
                        Sockets =
                        {
                            new Socket {
                                SocketType = SocketType.Blue
                            },
                        }
                    }
                }
            };

            this.socketsParserMock.Setup(x => x.Parse(It.IsAny <string>()))
            .Returns(expected);

            EquippableItem result = this.ItemParser.Parse(itemStringLines) as EquippableItem;

            Assert.That(result.Sockets, Is.EqualTo(expected));
        }
Exemplo n.º 3
0
        public void ParseShouldReturnEmptyItemSocketsIfStringIsNullOrWhitespace(string socketsString)
        {
            ItemSockets result = this.socketsParser.Parse(socketsString);

            Assert.NotNull(result);
            Assert.That(result.Count, Is.EqualTo(0));
        }
Exemplo n.º 4
0
        private ItemSockets GetSockets(string[] itemStringLines)
        {
            string socketsLine   = itemStringLines.FirstOrDefault(l => l.Contains(Contract.Properties.Resources.SocketsDescriptor));
            string socketsString = socketsLine?.Replace(Contract.Properties.Resources.SocketsDescriptor, "").Trim();

            ItemSockets itemSockets = this.socketsParser.Parse(socketsString);

            return(itemSockets);
        }
Exemplo n.º 5
0
        public void ParseShouldParseLinkedSockets()
        {
            ItemSockets result = this.socketsParser.Parse("R-B");

            Assert.NotNull(result);
            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result.SocketGroups.Count, Is.EqualTo(1));

            CheckSocketGroup(result.SocketGroups, 0, SocketType.Red, SocketType.Blue);
        }
Exemplo n.º 6
0
        public void ParseShouldParseSingleSocket(string socketsString, SocketType expected)
        {
            ItemSockets result = this.socketsParser.Parse(socketsString);

            Assert.NotNull(result);
            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result.SocketGroups.Count, Is.EqualTo(1));

            CheckSocketGroup(result.SocketGroups, 0, expected);
        }
Exemplo n.º 7
0
        public ItemSockets Parse(string socketsString)
        {
            var itemSockets = new ItemSockets();

            if (!string.IsNullOrWhiteSpace(socketsString))
            {
                AddSocketGroups(itemSockets, socketsString);
            }

            return(itemSockets);
        }
Exemplo n.º 8
0
        public void ParseShouldParseMultipleLinkedSocketGroups()
        {
            ItemSockets result = this.socketsParser.Parse("R-B W-G");

            Assert.NotNull(result);
            Assert.That(result.Count, Is.EqualTo(4));
            Assert.That(result.SocketGroups.Count, Is.EqualTo(2));

            CheckSocketGroup(result.SocketGroups, 0, SocketType.Red, SocketType.Blue);
            CheckSocketGroup(result.SocketGroups, 1, SocketType.White, SocketType.Green);
        }
Exemplo n.º 9
0
        public void ParseShouldParseTwoSingleSockets(string socketsString, params SocketType[] expected)
        {
            ItemSockets result = this.socketsParser.Parse(socketsString);

            Assert.NotNull(result);
            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result.SocketGroups.Count, Is.EqualTo(2));

            CheckSocketGroup(result.SocketGroups, 0, expected[0]);
            CheckSocketGroup(result.SocketGroups, 1, expected[1]);
        }
 private static void AddSocketsTillMaxSocketCount(int linkCount, ItemSockets result)
 {
     if (linkCount < 6)
     {
         for (int i = 6 - linkCount; i > 0; i--)
         {
             result.SocketGroups.Add(new SocketGroup
             {
                 Sockets =
                 {
                     new Socket()
                 }
             });
         }
     }
 }
        private static ItemSockets GetLinkedItemSockets(int linkCount)
        {
            var result = new ItemSockets();

            if (linkCount > 0)
            {
                var socketGroup = new SocketGroup();

                for (int i = 0; i < linkCount; i++)
                {
                    socketGroup.Sockets.Add(new Socket());
                }

                result.SocketGroups.Add(socketGroup);
            }

            AddSocketsTillMaxSocketCount(linkCount, result);

            return(result);
        }