private void ReadNetwork_OnClick(object sender, RoutedEventArgs e) { var filename = GetPathFromDialog(); try { _network = _networkInfoRetriever.Read(filename) as Network; ReasignNetwork(); MessageBox.Show("File loaded!", "OK", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.None); _headerUpdater?.Stop(); _headerUpdater = null; _backgroundWorker?.Stop(); _backgroundWorker = null; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.None); } }
public void ReadShouldReturnCorrectNetworkFromFile() { // Arrange // Act var network = _networkInfoRetriever.Read(ReadFilename); // Assert Assert.That(network.Nodes.Length, Is.EqualTo(_network.Nodes.Length)); Assert.That(network.Channels.Length, Is.EqualTo(_network.Channels.Length)); foreach (var node in network.Nodes) { Assert.IsTrue(_network.Nodes.Any(n => n.Id == node.Id)); } foreach (var channel in network.Channels) { var currentChannel = _network.Channels .First(c => c.Id == channel.Id); Assert.That(channel.FirstNodeId, Is.EqualTo(currentChannel.FirstNodeId)); Assert.That(channel.SecondNodeId, Is.EqualTo(currentChannel.SecondNodeId)); Assert.That(channel.ChannelType, Is.EqualTo(currentChannel.ChannelType)); Assert.That(channel.ConnectionType, Is.EqualTo(currentChannel.ConnectionType)); Assert.That(channel.Price, Is.EqualTo(currentChannel.Price)); Assert.That(channel.ErrorChance, Is.EqualTo(currentChannel.ErrorChance)); } }