public void WriteSettingsFile_DoesNotSaveFile_WhenNoNodesAvailable() { xDoc.Setup(x => x.LoadEx(Example2a_2.SettingsFile)) .Returns(xDoc.Object); xDoc.Setup(x => x.Descendants("someNodeName")) .Returns(new List <XElement>()); var vm = new Example2a_2(xDoc.Object); vm.WriteSettingsFile(); xDoc.Verify(x => x.Save(Example2a_2.SettingsFile), Times.Never); }
public void WriteSettingsFile_SavesFile_WhenNodesAvailable() { xDoc.Setup(x => x.LoadEx(Example2a_2.SettingsFile)) .Returns(xDoc.Object); xDoc.Setup(x => x.Descendants("someNodeName")) .Returns(new List<XElement> {new XElement("someNodeName")}); var vm = new Example2a_2(xDoc.Object); vm.WriteSettingsFile(); xDoc.Verify(x => x.Save(Example2a_2.SettingsFile), Times.Once()); }