public void Indexer_IdentifierExists_ReturnsCorrectNode() { var structure = new BsfStruct { ["Node"] = new BsfInt(1) }; Assert.AreEqual(1, ((BsfInt)structure["Node"]).Value); }
public void Get_IdentifierExists_ReturnsCorrectNode() { var structure = new BsfStruct { ["Node"] = new BsfInt(1) }; Assert.AreEqual(1, structure.Get <BsfInt>("Node").Value); }
public void Get_IdentifierExistsButInvalidType_ThrowsInvalidCastException() { var structure = new BsfStruct { ["Node"] = new BsfInt(1) }; Assert.Throws <InvalidCastException>(() => structure.Get <BsfBool>("Node")); }
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));