< Summary

Class:GDX.DataTables.DataTableMetaData
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/DataTables/DataTableMetaData.cs
Covered lines:4
Uncovered lines:25
Coverable lines:29
Total lines:109
Line coverage:13.7% (4 of 29)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:5
Method coverage:40% (2 of 5)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DataTableMetaData()0%110100%
SetBinding(...)0%6200%
ValidateBinding(...)0%12300%
CreateBinding(...)0%6200%
HasBinding()0%110100%

File(s)

./Packages/com.dotbunny.gdx/GDX/DataTables/DataTableMetaData.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System;
 6using System.IO;
 7using GDX.DataTables.DataBinding;
 8using UnityEngine;
 9
 10namespace GDX.DataTables
 11{
 12    /// <summary>
 13    ///     A collection of metadata for a <see cref="DataTableBase" />.
 14    /// </summary>
 15    /// <remarks>
 16    ///     These objects are created with the <see cref="HideFlags" /> preventing them from entering a build,
 17    ///     or being seen/editted directly in the editor.
 18    /// </remarks>
 19    public class DataTableMetaData : ScriptableObject
 20    {
 21#pragma warning disable IDE1006
 22        // ReSharper disable InconsistentNaming
 23
 24        /// <summary>
 25        ///     A `source of truth` binding for the data found in the <see cref="DataTableBase" />.
 26        /// </summary>
 27        /// <remarks>
 28        ///     On-disk bindings are relative to the asset folder.
 29        /// </remarks>
 30        public string BindingUri;
 31
 32        /// <summary>
 33        ///     The timestamp last gotten from the binding.
 34        /// </summary>
 35        public DateTime BindingTimestamp;
 36
 37        /// <summary>
 38        ///     The data version number used the last time data was pushed to the binding.
 39        /// </summary>
 40        public ulong BindingDataVersion;
 41
 42        /// <summary>
 43        ///     The user-friendly name used throughout the author-time experience for the <see cref="DataTableBase" />.
 44        /// </summary>
 545        public string DisplayName = "GDX DataTable";
 46
 47        /// <summary>
 48        ///     Locks out fields on the <see cref="DataTableBase" /> which are not reference based.
 49        ///     This is useful for when a dataset is being driven by a binding.
 50        /// </summary>
 51        public bool ReferencesOnlyMode;
 52
 53        /// <summary>
 54        ///     EXPERIMENTAL! Supports undo/redo operations on the <see cref="DataTableBase" />.
 55        /// </summary>
 56        public bool SupportsUndo;
 57
 58        // ReSharper enable InconsistentNaming
 59#pragma warning restore IDE1006
 60
 61#if UNITY_2021_3_OR_NEWER
 62
 63        public void SetBinding(string uri)
 064        {
 065            if (ValidateBinding(uri) != null)
 066            {
 067                BindingUri = uri;
 068            }
 69            else
 070            {
 071                BindingUri = null;
 072            }
 073        }
 74
 75        public static FormatBase ValidateBinding(string uri)
 076        {
 077            if (uri == null)
 078            {
 079                return null;
 80            }
 81
 082            string filePath = Path.Combine(Application.dataPath, uri);
 083            if (File.Exists(filePath))
 084            {
 085                return DataBindingProvider.GetFormatFromFile(filePath);
 86            }
 87
 088            return DataBindingProvider.GetFormatFromUri(uri);
 089        }
 90
 91        public static string CreateBinding(string uri)
 092        {
 93            // Convert to relative path, given this is stored in the Unity project we will need it in this form.
 094            if (File.Exists(uri))
 095            {
 096                return Path.GetRelativePath(Application.dataPath, uri);
 97            }
 98
 099            return uri;
 0100        }
 101
 102        public bool HasBinding()
 28103        {
 28104            return BindingUri != null;
 28105        }
 106
 107#endif // UNITY_2021_3_OR_NEWER
 108    }
 109}

Coverage by test methods






Methods/Properties

DataTableMetaData()
SetBinding(System.String)
ValidateBinding(System.String)
CreateBinding(System.String)
HasBinding()