public void Depots_should_be_persisted(bool isEstablished, bool isSurveyed) { var configNode = new ConfigNode(); var expectedBody = "Mun"; var expectedBiome = "East Crater"; var depot = new Depot(expectedBody, expectedBiome); if (isEstablished) { depot.Establish(); } if (isSurveyed) { depot.Survey(); } var persister = new TestPersister(); persister.Depots.Add(depot); var expectedResource = "ElectricCharge"; var expectedIncoming = 10; var expectedOutgoing = 7; var providedResources = new Dictionary <string, int> { { expectedResource, expectedIncoming } }; var consumedResources = new Dictionary <string, int> { { expectedResource, expectedOutgoing } }; depot.NegotiateProvider(providedResources); depot.NegotiateConsumer(consumedResources); persister.OnSave(configNode); Assert.True(configNode.HasNode(ScenarioPersister.DEPOTS_NODE_NAME)); var wolfNode = configNode.GetNode(ScenarioPersister.DEPOTS_NODE_NAME); Assert.True(wolfNode.HasData); var depotNodes = wolfNode.GetNodes(); var depotNode = depotNodes.First(); Assert.True(depotNode.HasValue("Body")); Assert.True(depotNode.HasValue("Biome")); Assert.True(depotNode.HasValue("IsEstablished")); Assert.True(depotNode.HasValue("IsSurveyed")); var bodyValue = depotNode.GetValue("Body"); var biomeVaue = depotNode.GetValue("Biome"); bool establishedValue = false; var establishedValueWasParsed = depotNode.TryGetValue("IsEstablished", ref establishedValue); bool surveyedValue = false; var surveyedValueWasParsed = depotNode.TryGetValue("IsSurveyed", ref surveyedValue); Assert.True(establishedValueWasParsed); Assert.True(surveyedValueWasParsed); Assert.Equal(expectedBody, bodyValue); Assert.Equal(expectedBiome, biomeVaue); Assert.Equal(isEstablished, establishedValue); Assert.Equal(isSurveyed, surveyedValue); Assert.True(depotNode.HasNode("RESOURCE")); var resourceNode = depotNode.GetNodes().First(); Assert.True(resourceNode.HasValue("ResourceName")); Assert.True(resourceNode.HasValue("Incoming")); Assert.True(resourceNode.HasValue("Outgoing")); var nodeResourceName = resourceNode.GetValue("ResourceName"); var nodeIncomingValue = int.Parse(resourceNode.GetValue("Incoming")); var nodeOutgoingValue = int.Parse(resourceNode.GetValue("Outgoing")); Assert.Equal(expectedResource, nodeResourceName); Assert.Equal(expectedIncoming, nodeIncomingValue); Assert.Equal(expectedOutgoing, nodeOutgoingValue); }