Exemple #1
0
        public void Indexer_IdentifierExists_ReturnsCorrectNode()
        {
            var structure = new BsfStruct {
                ["Node"] = new BsfInt(1)
            };

            Assert.AreEqual(1, ((BsfInt)structure["Node"]).Value);
        }
Exemple #2
0
        public void Get_IdentifierExists_ReturnsCorrectNode()
        {
            var structure = new BsfStruct {
                ["Node"] = new BsfInt(1)
            };

            Assert.AreEqual(1, structure.Get <BsfInt>("Node").Value);
        }
Exemple #3
0
        public void Get_IdentifierExistsButInvalidType_ThrowsInvalidCastException()
        {
            var structure = new BsfStruct {
                ["Node"] = new BsfInt(1)
            };

            Assert.Throws <InvalidCastException>(() => structure.Get <BsfBool>("Node"));
        }
Exemple #4
0
        public void Indexer_OverridingValue_DoesNotThrow()
        {
            var structure = new BsfStruct {
                ["Node"] = new BsfInt(1)
            };

            Assert.DoesNotThrow(() => structure["Node"] = new BsfBool(true));
            Assert.DoesNotThrow(() => structure["Node"] = null);
        }
 /// <summary>
 /// Constructs a new binary-structure-format file with the given structure.
 /// </summary>
 /// <param name="root">Root of the structure. Cannot be null.</param>
 public BsfFile(BsfStruct root) => Root = root ?? throw new ArgumentNullException(nameof(root));