public void BuildShouldReturnNetworkWithOneCentralMachine() { // Arrange // Act var result = _networkBuilder.Build(); // Assert Assert.That(result.Nodes.Count(n => n.NodeType == NodeType.CentralMachine), Is.EqualTo(1)); }
public void BuildShouldTwoNetworksWithDifferentIds(int nodeCount, double networkPower) { // Arrange _networkBuilder = new NetworkBuilder(_nodeGeneratorMock.Object, nodeCount, networkPower); var firstNetwork = _networkBuilder.Build(); // Act var result = _networkBuilder.Build(); // Assert foreach (var node in result.Nodes) { Assert.IsFalse(firstNetwork.Nodes.Any(n => n.Id == node.Id)); } }
private IList <INetworkHandler> CreateMetropolianNetworks() { var metropolitanNetworks = new List <INetworkHandler>(); for (var i = 0; i < _numberOfMetropolitanNetworks; i++) { var network = _simpleNetworkBuilder.Build(); metropolitanNetworks.Add(network); } return(metropolitanNetworks); }
private INetworkHandler CreateNetwork() { var metropolitanNodesCount = int.Parse(MetropolitanNodesNumber.Text); var metropolitanNetworksCount = int.Parse(MetropolitanNetworksCount.Text); var networkPower = double.Parse(NetworkPower.Text); _nodeGenerator = new NodeGenerator(); _nodeGenerator.ResetAccumulator(); _simpleNetworkBuilder = new NetworkBuilder(_nodeGenerator, metropolitanNodesCount, networkPower); _networkBuilder = new WideAreaNetworkBuilder(_simpleNetworkBuilder, metropolitanNetworksCount); var network = _networkBuilder.Build(); return(network); }
public void BuildShouldCreateCorrectNetworkSpecifiedNumberOfTimesWithSpecifiedParameters(int nodeCount, double networkPower, double eps) { for (var i = 0; i < TimesToCreateNetwork; i++) { // Arrange _networkBuilder = new NetworkBuilder(_nodeGeneratorMock.Object, nodeCount, networkPower); // Act var network = _networkBuilder.Build(); var currentPower = network.Channels.Length * 2 / (double)nodeCount; var isAllPricesIsAvailable = network.Channels .Select(c => c.Price) .All(p => _availablePrices.Contains(p)); // Assert Assert.That(network.Nodes.Length, Is.EqualTo(nodeCount)); Assert.That(network.Channels.Length, Is.GreaterThan(0)); Assert.IsTrue(isAllPricesIsAvailable); Assert.That(Math.Abs(currentPower - networkPower), Is.LessThanOrEqualTo(eps)); LogResult(i, networkPower, currentPower); } }