Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CodeChallengeV2/Services/NetworkSimulatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@ public class NetworkSimulatorService : INetworkSimulatorService
/// <returns></returns>
public Task<List<Node>> FindCritialGateways(NetworkGraph graph)
{
return Task.FromResult(Enumerable.Empty<Node>().ToList());
var output = new List<Node>();
var devices = graph.Graphs[0].Nodes.Where(x => x.Type == "Device");
var gateways = graph.Graphs[0].Nodes.Where(x => x.Type == "Gateway");
foreach (var node in devices)
{
var edges = graph.Graphs[0].Edges.Where(x => x.Source == node.Id);
if (edges.Count() == 1)
{
var edge = edges.FirstOrDefault();
var gateway = gateways.Where(x => x.Id == edge.Target).FirstOrDefault();
if (!output.Contains(gateway))
{
output.Add(gateway);
}
}
}
return Task.FromResult(output);
}
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY . .

RUN dotnet build "CodeChallengeV2/CodeChallengeV2.csproj" -c Release -o /app

RUN dotnet test "CodeChallengeV2.Tests/CodeChallengeV2.Tests.csproj" -c Release -o /app
#RUN dotnet test "CodeChallengeV2.Tests/CodeChallengeV2.Tests.csproj" -c Release -o /app



Expand Down