Exemplo n.º 1
0
        public async Task <List <Node> > GetDatasetNodes(int datasetId)
        {
            var links = await datasetsService.GetDatasetLinks(datasetId);

            var users = await datasetsService.GetOrderedUsers(links);

            var nodes = users.Select(id => new Node()
            {
                Id = id
            }).ToList();

            return(nodes);
        }
Exemplo n.º 2
0
        public async void TestGetOrderedUsers()
        {
            List <Link> input = new List <Link>()
            {
                new Link()
                {
                    User1Id = 0, User2Id = 1
                }, new Link()
                {
                    User1Id = 0, User2Id = 2
                },
                new Link()
                {
                    User1Id = 0, User2Id = 3
                }, new Link()
                {
                    User1Id = 0, User2Id = 8
                },
                new Link()
                {
                    User1Id = 1, User2Id = 2
                }, new Link()
                {
                    User1Id = 1, User2Id = 11
                },
                new Link()
                {
                    User1Id = 1, User2Id = 3
                }, new Link()
                {
                    User1Id = 1, User2Id = 4
                },
                new Link()
                {
                    User1Id = 2, User2Id = 3
                }, new Link()
                {
                    User1Id = 2, User2Id = 4
                },
                new Link()
                {
                    User1Id = 3, User2Id = 4
                }, new Link()
                {
                    User1Id = 3, User2Id = 7
                },
                new Link()
                {
                    User1Id = 13, User2Id = 4
                }, new Link()
                {
                    User1Id = 2, User2Id = 99
                }
            };

            List <int> expectedOutput = new List <int>()
            {
                0, 1, 2, 3, 4, 7, 8, 11, 13, 99
            };
            List <int> actualOutput = await datasetService.GetOrderedUsers(input);

            Assert.True(expectedOutput.Count == actualOutput.Count);

            for (int i = 0; i < actualOutput.Count; i++)
            {
                Assert.Equal(expectedOutput[i], actualOutput[i]);
            }
        }