< Summary

Line coverage
95%
Covered lines: 22
Uncovered lines: 1
Coverable lines: 23
Total lines: 69
Line coverage: 95.6%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
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%22100%
FromStream(...)100%11100%
WriteTo(...)50%2.02283.33%
WriteTo(...)100%22100%

File(s)

https://raw.githubusercontent.com/JeremyAnsel/JeremyAnsel.Media.WavefrontObj/dbbfcd213b7c54f49194f82fcd56e790cca193c3/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    {
 87614        public ObjMaterialFile()
 15        {
 87616            this.Materials = new List<ObjMaterial>();
 87617        }
 18
 46819        public string? HeaderText { get; set; }
 20
 21        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
 301822        public List<ObjMaterial> Materials { get; private set; }
 23
 24        public static ObjMaterialFile FromFile(string? path)
 25        {
 626            if (path == null)
 27            {
 328                throw new ArgumentNullException(nameof(path));
 29            }
 30
 331            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
 32            {
 333                return ObjMaterialFileReader.FromStream(stream);
 34            }
 335        }
 36
 37        public static ObjMaterialFile FromStream(Stream? stream)
 38        {
 67539            return ObjMaterialFileReader.FromStream(stream);
 40        }
 41
 42        public void WriteTo(string? path)
 43        {
 344            if (path == null)
 45            {
 046                throw new ArgumentNullException(nameof(path));
 47            }
 48
 349            using (var writer = new StreamWriter(path))
 50            {
 351                ObjMaterialFileWriter.Write(this, writer);
 352            }
 353        }
 54
 55        public void WriteTo(Stream? stream)
 56        {
 19857            if (stream == null)
 58            {
 359                throw new ArgumentNullException(nameof(stream));
 60            }
 61
 19562            using (var writer = new StreamWriter(stream, new UTF8Encoding(false, true), 1024, true))
 63            {
 19564                ObjMaterialFileWriter.Write(this, writer);
 19565            }
 19566        }
 67    }
 68}
 69