public void JsonExport_isTrue() { var saveDialogMock = new Mock <ISaveFile>(); var openDialogMock = new Mock <IOpenFile>(); saveDialogMock.Setup(x => x.ShowDialog()).Returns(true).Verifiable(); saveDialogMock.Setup(x => x.FileName).Returns(_expectedFileName).Verifiable(); openDialogMock.Setup(x => x.ShowDialog()).Returns(true).Verifiable(); openDialogMock.Setup(x => x.FileName).Returns(_expectedFileName).Verifiable(); _jsonManager = new JsonManager(saveDialogMock.Object, openDialogMock.Object); bool erg = _jsonManager.JsonExport(_tourList, _logList); saveDialogMock.Verify(); Assert.True(erg); Assert.True(File.Exists(_expectedFileName)); if (File.Exists(_expectedFileName)) { File.Delete(_expectedFileName); } }
public void JsonExport_NoFilename_Cancelled() { _expectedFileName = ""; var saveDialogMock = new Mock <ISaveFile>(); var openDialogMock = new Mock <IOpenFile>(); saveDialogMock.Setup(x => x.ShowDialog()).Returns(true).Verifiable(); saveDialogMock.Setup(x => x.FileName).Returns(_expectedFileName).Verifiable(); openDialogMock.Setup(x => x.ShowDialog()).Returns(true).Verifiable(); openDialogMock.Setup(x => x.FileName).Returns(_expectedFileName).Verifiable(); _jsonManager = new JsonManager(saveDialogMock.Object, openDialogMock.Object); bool erg = _jsonManager.JsonExport(_tourList, _logList); saveDialogMock.Verify(); Assert.False(erg); Assert.False(File.Exists(_expectedFileName)); }