Skip to content

Instantly share code, notes, and snippets.

@neilharvey
Created October 25, 2019 07:00
Show Gist options
  • Select an option

  • Save neilharvey/d12c66505ff31d3a101bf58ee85d918e to your computer and use it in GitHub Desktop.

Select an option

Save neilharvey/d12c66505ff31d3a101bf58ee85d918e to your computer and use it in GitHub Desktop.
using FileSignatures.Formats;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Xunit;
namespace FileSignatures.Tests
{
public class RegistrationTests
{
[Fact]
public void CanBeRegisteredAsSingleton()
{
var services = new ServiceCollection();
services.AddSingleton<IFileFormatInspector>(x => new FileFormatInspector());
var provider = services.BuildServiceProvider();
var jpegHeader = new byte[] { 0xFF, 0xD8 };
using var stream = new MemoryStream(jpegHeader);
var inspector = provider.GetService<IFileFormatInspector>();
var result = inspector.DetermineFileFormat(stream);
Assert.NotNull(result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment