Commenting out unused test. (#23)

This commit is contained in:
Steve Smith
2017-07-28 23:27:41 -04:00
committed by GitHub
parent acdc072cb9
commit 12cbd595d0

View File

@@ -9,75 +9,75 @@ using Xunit;
namespace UnitTests
{
public class CatalogControllerGetImage
{
private Mock<IImageService> _mockImageService = new Mock<IImageService>();
private Mock<IAppLogger<CatalogController>> _mockLogger = new Mock<IAppLogger<CatalogController>>();
private CatalogController _controller;
private int _testImageId = 123;
private byte[] _testBytes = { 0x01, 0x02, 0x03 };
//public class CatalogControllerGetImage
//{
// private Mock<IImageService> _mockImageService = new Mock<IImageService>();
// private Mock<IAppLogger<CatalogController>> _mockLogger = new Mock<IAppLogger<CatalogController>>();
// private CatalogController _controller;
// private int _testImageId = 123;
// private byte[] _testBytes = { 0x01, 0x02, 0x03 };
public CatalogControllerGetImage()
{
_controller = new CatalogController(null, null, _mockImageService.Object,
_mockLogger.Object);
}
// public CatalogControllerGetImage()
// {
// _controller = new CatalogController(null, null, _mockImageService.Object,
// _mockLogger.Object);
// }
[Fact]
public void CallsImageServiceWithId()
{
SetupImageWithTestBytes();
// [Fact]
// public void CallsImageServiceWithId()
// {
// SetupImageWithTestBytes();
_controller.GetImage(_testImageId);
_mockImageService.Verify();
}
// _controller.GetImage(_testImageId);
// _mockImageService.Verify();
// }
[Fact]
public void ReturnsFileResultWithBytesGivenSuccess()
{
SetupImageWithTestBytes();
// [Fact]
// public void ReturnsFileResultWithBytesGivenSuccess()
// {
// SetupImageWithTestBytes();
var result = _controller.GetImage(_testImageId);
// var result = _controller.GetImage(_testImageId);
var fileResult = Assert.IsType<FileContentResult>(result);
var bytes = Assert.IsType<byte[]>(fileResult.FileContents);
}
// var fileResult = Assert.IsType<FileContentResult>(result);
// var bytes = Assert.IsType<byte[]>(fileResult.FileContents);
// }
[Fact]
public void ReturnsNotFoundResultGivenImageMissingException()
{
SetupMissingImage();
// [Fact]
// public void ReturnsNotFoundResultGivenImageMissingException()
// {
// SetupMissingImage();
var result = _controller.GetImage(_testImageId);
// var result = _controller.GetImage(_testImageId);
var actionResult = Assert.IsType<NotFoundResult>(result);
}
// var actionResult = Assert.IsType<NotFoundResult>(result);
// }
[Fact]
public void LogsWarningGivenImageMissingException()
{
SetupMissingImage();
_mockLogger.Setup(l => l.LogWarning(It.IsAny<string>()))
.Verifiable();
// [Fact]
// public void LogsWarningGivenImageMissingException()
// {
// SetupMissingImage();
// _mockLogger.Setup(l => l.LogWarning(It.IsAny<string>()))
// .Verifiable();
_controller.GetImage(_testImageId);
// _controller.GetImage(_testImageId);
_mockLogger.Verify();
}
// _mockLogger.Verify();
// }
private void SetupMissingImage()
{
_mockImageService
.Setup(i => i.GetImageBytesById(_testImageId))
.Throws(new CatalogImageMissingException("missing image"));
}
// private void SetupMissingImage()
// {
// _mockImageService
// .Setup(i => i.GetImageBytesById(_testImageId))
// .Throws(new CatalogImageMissingException("missing image"));
// }
private void SetupImageWithTestBytes()
{
_mockImageService
.Setup(i => i.GetImageBytesById(_testImageId))
.Returns(_testBytes)
.Verifiable();
}
}
// private void SetupImageWithTestBytes()
// {
// _mockImageService
// .Setup(i => i.GetImageBytesById(_testImageId))
// .Returns(_testBytes)
// .Verifiable();
// }
//}
}