public IObjLoader Create(IMaterialStreamProvider materialStreamProvider) { var dataStore = new DataStore(); var faceParser = new FaceParser(dataStore); var groupParser = new GroupParser(dataStore); var normalParser = new NormalParser(dataStore); var textureParser = new TextureParser(dataStore); var vertexParser = new VertexParser(dataStore); var materialLibraryLoader = new MaterialLibraryLoader(dataStore); var materialLibraryLoaderFacade = new MaterialLibraryLoaderFacade(materialLibraryLoader, materialStreamProvider); var materialLibraryParser = new MaterialLibraryParser(materialLibraryLoaderFacade); var useMaterialParser = new UseMaterialParser(dataStore); return new ObjLoader(dataStore, faceParser, groupParser, normalParser, textureParser, vertexParser, materialLibraryParser, useMaterialParser); }
public void SetUp() { _textureDataStore = new DataStore(); _faceParser = new FaceParser(_textureDataStore); _groupParser = new GroupParser(_textureDataStore); _normalParser = new NormalParser(_textureDataStore); _textureParser = new TextureParser(_textureDataStore); _vertexParser = new VertexParser(_textureDataStore); _materialStreamProviderSpy = new MaterialStreamProviderSpy(); _materialStreamProviderSpy.StreamToReturn = CreateMemoryStreamFromString(MaterialLibraryString); _materialLibraryLoader = new MaterialLibraryLoader(_textureDataStore); _materialLibraryLoaderFacade = new MaterialLibraryLoaderFacade(_materialLibraryLoader, _materialStreamProviderSpy); _materialLibraryParser = new MaterialLibraryParser(_materialLibraryLoaderFacade); _useMaterialParser = new UseMaterialParser(_textureDataStore); _loader = new Loader.Loaders.ObjLoader(_textureDataStore, _faceParser, _groupParser, _normalParser, _textureParser, _vertexParser, _materialLibraryParser, _useMaterialParser); }
public void Loads_object_correctly_when_material_is_not_found() { _materialStreamProviderSpy.StreamToReturn = null; var materialLibraryLoaderFacade = new MaterialLibraryLoaderFacade(_materialLibraryLoader, _materialStreamProviderSpy); var materialLibraryParser = new MaterialLibraryParser(materialLibraryLoaderFacade); _loader = new Loader.Loaders.ObjLoader(_textureDataStore, _faceParser, _groupParser, _normalParser, _textureParser, _vertexParser, materialLibraryParser, _useMaterialParser); Load(); _loadResult.Vertices.Should().HaveCount(8); _loadResult.Textures.Should().HaveCount(14); _loadResult.Normals.Should().HaveCount(8); _loadResult.Materials.Should().HaveCount(0); _loadResult.Groups.Should().HaveCount(1); var group = _loadResult.Groups.First(); group.Faces.Should().HaveCount(12); group.Material.Should().BeNull(); }