BinaryDataWithContentLoaderTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Content.Tests BinaryDataWithContentLoaderTests

Namespace: DeltaEngine.Content.Tests
Assembly: DeltaEngine.Content.Tests (in DeltaEngine.Content.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class BinaryDataWithContentLoaderTests

The BinaryDataWithContentLoaderTests type exposes the following members.

Constructors

  NameDescription
Public methodBinaryDataWithContentLoaderTests
Initializes a new instance of the BinaryDataWithContentLoaderTests class
Top
Methods

  NameDescription
Public methodLoadContentWithoutNameShouldThrowUnableToLoadContentDataWithoutName
Public methodTestLoadContentType
Top
Examples

[Test]
public void TestLoadContentType()
{
    ContentLoader.Use<MockContentLoader>();
    const string ContentName = "SomeXml";
    var instance = new ObjectWithContent(ContentLoader.Load<MockXmlContent>(ContentName));
    var stream = BinaryDataExtensions.SaveDataIntoMemoryStream(instance);
    var loadedInstance =
        BinaryDataExtensions.LoadDataWithKnownTypeFromMemoryStream<ObjectWithContent>(stream);
    Assert.AreEqual(instance.xmlContent, loadedInstance.xmlContent);
    ContentLoader.DisposeIfInitialized();
}
[Test]
public void LoadContentWithoutNameShouldThrowUnableToLoadContentDataWithoutName()
{
    var stream = new MemoryStream();
    var writer = new BinaryWriter(stream);
    writer.Write(true);
    writer.Write(string.Empty);
    ContentLoader.Use<MockContentLoader>();
    stream.Position = 0;
    var reader = new BinaryReader(stream);
    var version = Assembly.GetExecutingAssembly().GetName().Version;
    Assert.That(
        () => BinaryDataLoader.CreateAndLoad(typeof(MockXmlContent), reader, version),
        Throws.Exception.With.InnerException.TypeOf
            <BinaryDataLoader.UnableToLoadContentDataWithoutName>());
    ContentLoader.DisposeIfInitialized();
}
See Also