Class AssetFileSnapshot
One asset file's bytes and timestamp, taken before a test drives code that must not write it, so the test
can tell whether it was written — marked dirty, or changed on disk — and put it back exactly as it was
when it was. Putting the timestamp back too keeps every assembly's shipped-content residue guard seeing
the file as this test found it, so a red run never leaves the package modified.
Inheritance
AssetFileSnapshot
Assembly: Serenity.Tests.Shared.Editor.dll
Syntax
public sealed class AssetFileSnapshot
Properties
AssetPath
The project-relative path the snapshot was taken of.
Declaration
public string AssetPath { get; }
Property Value
BytesChanged
True when the file on disk no longer holds the bytes this snapshot read.
Declaration
public bool BytesChanged { get; }
Property Value
TimestampChanged
True when the file was rewritten since this snapshot, even with the same bytes.
Declaration
public bool TimestampChanged { get; }
Property Value
Methods
RestoreIfWritten(Object)
Clears the dirty mark, puts the bytes back, reimports so the loaded object reads them again,
and restores the timestamp — only when WasWritten(Object) says there is something to undo.
Declaration
public void RestoreIfWritten(Object asset)
Parameters
| Type |
Name |
Description |
| Object |
asset |
|
Take(string)
Reads the bytes and the timestamp of the file at assetPath.
Declaration
public static AssetFileSnapshot Take(string assetPath)
Parameters
| Type |
Name |
Description |
| string |
assetPath |
|
Returns
WasWritten(Object)
True when asset was marked dirty or its file was rewritten — a change that
is only marked is still a write, because the next save of anything persists it, and a save that
reproduced the same bytes still touched a file the author never asked to have touched.
Declaration
public bool WasWritten(Object asset)
Parameters
| Type |
Name |
Description |
| Object |
asset |
|
Returns