< Summary

Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 87
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_HeaderText()100%11100%
get_Materials()100%11100%
FromFile(...)100%11100%
FromFile(...)100%22100%
FromStream(...)100%11100%
FromStream(...)100%11100%
FromStream(...)100%11100%
WriteTo(...)100%22100%
WriteTo(...)100%22100%

File(s)

https://raw.githubusercontent.com/JeremyAnsel/JeremyAnsel.Media.WavefrontObj/7b5b951766c69f14731a856f32198cdbf1fc6847/JeremyAnsel.Media.WavefrontObj/JeremyAnsel.Media.WavefrontObj/ObjMaterialFile.cs

#LineLine coverage
 1// <copyright file="ObjMaterialFile.cs" company="Jérémy Ansel">
 2// Copyright (c) 2017, 2019 Jérémy Ansel
 3// </copyright>
 4// <license>
 5// Licensed under the MIT license. See LICENSE.txt
 6// </license>
 7
 8using System.Text;
 9
 10namespace JeremyAnsel.Media.WavefrontObj
 11{
 12    public class ObjMaterialFile
 13    {
 204414        public ObjMaterialFile()
 15        {
 204416            this.Materials = new List<ObjMaterial>();
 204417        }
 18
 147619        public string? HeaderText { get; set; }
 20
 21        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
 790422        public List<ObjMaterial> Materials { get; private set; }
 23
 24        public static ObjMaterialFile FromFile(string? path)
 25        {
 826            return FromFile(path, ObjMaterialFileReaderSettings.Default);
 27        }
 28
 29        public static ObjMaterialFile FromFile(string? path, ObjMaterialFileReaderSettings settings)
 30        {
 831            if (path == null)
 32            {
 433                throw new ArgumentNullException(nameof(path));
 34            }
 35
 436            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
 37            {
 38#if NET6_0_OR_GREATER
 339                return ObjMaterialFileReader9.FromStream(stream, settings);
 40#else
 141                return ObjMaterialFileReader.FromStream(stream, settings);
 42#endif
 43            }
 444        }
 45
 46        public static ObjMaterialFile FromStream(Stream? stream)
 47        {
 848            return FromStream(stream, ObjMaterialFileReaderSettings.Default);
 49        }
 50
 51        public static ObjMaterialFile FromStream(Stream? stream, ObjMaterialFileReaderSettings settings)
 52        {
 53#if NET6_0_OR_GREATER
 129654            return ObjMaterialFileReader9.FromStream(stream, settings);
 55#else
 43256            return ObjMaterialFileReader.FromStream(stream, settings);
 57#endif
 58        }
 59
 60        public void WriteTo(string? path)
 61        {
 862            if (path == null)
 63            {
 464                throw new ArgumentNullException(nameof(path));
 65            }
 66
 467            using (var writer = new StreamWriter(path))
 68            {
 469                ObjMaterialFileWriter.Write(this, writer);
 470            }
 471        }
 72
 73        public void WriteTo(Stream? stream)
 74        {
 30875            if (stream == null)
 76            {
 477                throw new ArgumentNullException(nameof(stream));
 78            }
 79
 30480            using (var writer = new StreamWriter(stream, new UTF8Encoding(false, true), 1024, true))
 81            {
 30482                ObjMaterialFileWriter.Write(this, writer);
 30483            }
 30484        }
 85    }
 86}
 87