public async Task <OperationResult <NodeCountPOCO> > GetNrNodesAsync() { return(await ExecuteFunction(async() => NodesCounter(await _nodeDAO.GetAllAsync()))); NodeCountPOCO NodesCounter(List <Node> list) { int total = 0, noRequesters = 0, noProviders = 0, noFull = 0, on = 0, off = 0; list.ForEach( it => { if (it.Type.Equals("Requester")) { noRequesters++; } if (it.Type.Equals("Producer")) { noProviders++; } if (it.Type.Equals("Full")) { noFull++; } if (it.Status.Equals("ON")) { on++; } else { off++; } total++; } ); return(new NodeCountPOCO(total, noFull, noRequesters, noProviders, on, off)); } }
public async Task TestGetAllNodes() { var inDB = new List <Node> { new Node { Account = "Full", Ip = "Mock", Service = "Mock", Type = "Full", Status = "ON" }, new Node { Account = "Requester", Ip = "Mock", Service = "Mock", Type = "Requester", Status = "ON" }, new Node { Account = "Producer", Ip = "Mock", Service = "Mock", Type = "Producer", Status = "ON" } }; var nodesDAO = new NodesDataAccessObject(); nodesDAO.TestDB(); var allnodes = await nodesDAO.GetAllAsync(); var b = allnodes.SequenceEqual(inDB); Assert.IsTrue(b); }