Пример #1
0
        public void Indexer_IdentifierExists_ReturnsCorrectNode()
        {
            var structure = new BsfStruct {
                ["Node"] = new BsfInt(1)
            };

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

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

            Assert.Throws <InvalidCastException>(() => structure.Get <BsfBool>("Node"));
        }
Пример #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);
        }
Пример #5
0
 /// <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));