public void GetFileName_DocumentFactoryReturningAnExtension_ShouldReturnFileNameWithExtension() { var exporter = new FileStreamExporter(_documentFactoryMock.Object, _exportTaskMock.Object, () => DateTime.Parse("2018/01/05 12:00")); _documentFactoryMock.SetupGet(x => x.FileExtension).Returns("xlsx"); Assert.That(exporter.GetFileName(), Is.EqualTo("SomeExportName 20180105.xlsx")); _documentFactoryMock.SetupGet(x => x.FileExtension).Returns(".zip"); Assert.That(exporter.GetFileName(), Is.EqualTo("SomeExportName 20180105.zip")); }
public void GetFileName_InvalidTaskName_ShouldThrowException() { var exporter = new FileStreamExporter(_documentFactoryMock.Object, _exportTaskMock.Object); _exportTaskMock.SetupGet(x => x.Name).Returns((string)null); var ex = Assert.Throws <InvalidOperationException>(() => exporter.GetFileName()); Assert.That(ex.Message, Is.EqualTo("Failed to get the name of the export task")); _exportTaskMock.SetupGet(x => x.Name).Returns(string.Empty); ex = Assert.Throws <InvalidOperationException>(() => exporter.GetFileName()); Assert.That(ex.Message, Is.EqualTo("Failed to get the name of the export task")); }
public void GetFileName_DocumentFactoryReturningEmptyStringAsExtension_ShouldReturnFileNameWithoutExtension() { _documentFactoryMock.SetupGet(x => x.FileExtension).Returns(string.Empty); var exporter = new FileStreamExporter(_documentFactoryMock.Object, _exportTaskMock.Object, () => DateTime.Parse("2018/01/05 12:00")); Assert.That(exporter.GetFileName(), Is.EqualTo("SomeExportName 20180105")); }