public void CheckExplicitlySetContentLoader()
 {
     ContentLoader.Use <DiskContentLoader>();
     CreateResolver();
     Assert.AreEqual(typeof(DiskContentLoader), ContentLoader.Type);
     ContentLoader.DisposeIfInitialized();
 }
Exemple #2
0
        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();
        }
Exemple #3
0
        public void GetLocalizedString()
        {
            ContentLoader.Use <MockContentLoader>();
            var localization = ContentLoader.Load <Localization>("Texts");

            localization.TwoLetterLanguageName = "en";
            Assert.AreEqual(localization.GetText("Go"), "Go");
            localization.TwoLetterLanguageName = "de";
            Assert.AreEqual(localization.GetText("Go"), "Los");
            localization.TwoLetterLanguageName = "es";
            Assert.AreEqual(localization.GetText("Go"), "¡vamos!");
            Assert.Throws <KeyNotFoundException>(
                () => localization.GetText("ThatIsATestExampleToThrowOneException"));
            ContentLoader.DisposeIfInitialized();
        }
        public void Connect(string userName, OnlineServiceConnection connection)
        {
            UserName = userName;
            onlineServiceConnection  = connection;
            connection.DataReceived += OnDataReceived;
            send = connection.Send;
            var oldResolver = ContentLoader.resolver;

            ContentLoader.DisposeIfInitialized();
            ContentLoader.resolver = oldResolver;
            ContentLoader.Use <EditorContentLoader>();
            editorContent = new EditorContentLoader(onlineServiceConnection);
            editorContent.ContentUpdated += OnContentUpdated;
            editorContent.ContentDeleted += OnContentDeleted;
            editorContent.ContentReady   += OnContentReady;
        }
Exemple #5
0
        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();
        }
Exemple #6
0
 public override void Dispose()
 {
     if (!onlineServiceReadyReceived && ContentLoader.current != null &&
         ContentLoader.current.StartedToRequestOnlineContent)
     {
         WaitUntilContentReadyReceivedOrServerErrorHappened();
     }
     base.Dispose();
     foreach (var instance in instancesToDispose)
     {
         instance.Dispose();
     }
     instancesToDispose.Clear();
     ContentLoader.DisposeIfInitialized();
     if (ScreenSpace.IsInitialized)
     {
         ScreenSpace.Current.Dispose();
     }
 }
        public void ConnectToOnlineContentServiceWithoutExistingContent()
        {
            if (Directory.Exists("Content"))
            {
                Directory.Delete("Content", true);
            }
            bool ready      = false;
            var  connection = new OnlineServiceConnection(new MockSettings(),
                                                          () => { throw new ConnectionTimedOut(); });

            connection.ServerErrorHappened += error => { throw new ServerErrorReceived(error); };
            connection.ContentReady        += () => ready = true;
            ContentLoaderResolver.CreationParameterForContentLoader = connection;
            ContentLoader.Use <DeveloperOnlineContentLoader>();
            Assert.IsTrue(ContentLoader.Exists("DeltaEngineLogo"));
            Assert.IsTrue(Directory.Exists("Content"));
            Assert.IsTrue(ready);
            ContentLoader.DisposeIfInitialized();
        }
 public void DisposeContentLoader()
 {
     ContentLoader.DisposeIfInitialized();
 }
Exemple #9
0
 public void DisposeContentLoaderAndDeleteContentDirectory()
 {
     ContentLoader.DisposeIfInitialized();
     DeleteDirectoryAndAllIncludingFiles(ContentProjectDirectoryName);
 }
 public void RunTestAndDisposeResolverWhenDone()
 {
     entities.Dispose();
     ContentLoader.DisposeIfInitialized();
 }