public void MediaServerTestGetMediaTest()
        {
            TestInfrastructure.DebugLineStart(TestContext);
            if (TestInfrastructure.IsActive(TestContext))
            {
                if (!(TestContext.DataRow["type"].ToString().ToLower() == "file"))
                {
                    using (MLifter.DAL.Interfaces.IDictionary testLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser))
                    {
                        Dictionary <int, int>       mediaIds = new Dictionary <int, int>();                 //key: idCounter, value: mediaId
                        Dictionary <string, byte[]> testData = new Dictionary <string, byte[]>();
                        //Filling DB with Test Data
                        for (int i = 0; i < TestInfrastructure.Loopcount; i++)
                        {
                            string testMedia = TestInfrastructure.GetTestImage();
                            testData.Add(testMedia, File.ReadAllBytes(testMedia));
                        }
                        int idCounter = 0;
                        //Putting Test Data into db
                        foreach (string testMedia in testData.Keys)
                        {
                            ICard  card  = testLM.Cards.Create();
                            IMedia media = card.AddMedia(card.CreateMedia(EMedia.Image, testMedia, true, true, false), Side.Question);
                            mediaIds[idCounter++] = media.Id;
                        }

                        //Create a new MediaServerInstance
                        DbMediaServer myMediaServer = DbMediaServer.Instance(8080, testLM.Parent);
                        myMediaServer.Start();

                        //Wait until server is ready
                        while (!myMediaServer.IsReady)
                        {
                            ;
                        }

                        //Verify
                        idCounter = 0;
                        foreach (string testMedia in testData.Keys)
                        {
                            Uri       theServerUri_itme = DbMediaServer.Instance(testLM.Parent).GetMediaURI(mediaIds[idCounter++]);
                            WebClient client            = new WebClient();
                            byte[]    downloadData_item = client.DownloadData(theServerUri_itme.ToString());
                            byte[]    b = testData[testMedia];

                            for (int i = 0; i < b.Length; i++)
                            {
                                Assert.IsTrue(b[i].Equals(downloadData_item[i]), "Test Data does not match");
                            }
                        }

                        //Stop the Media Server again
                        myMediaServer.Stop();
                    }
                }
            }
            TestInfrastructure.DebugLineEnd(TestContext);
        }
 public void MediaServerTestGetServerInstancTest()
 {
     TestInfrastructure.DebugLineStart(TestContext);
     if (TestInfrastructure.IsActive(TestContext))
     {
         if (!(TestContext.DataRow["type"].ToString().ToLower() == "file"))
         {
             using (MLifter.DAL.Interfaces.IDictionary testLM = TestInfrastructure.GetLMConnection(TestContext, string.Empty, false))
             {
                 DbMediaServer myMediaServer = DbMediaServer.Instance(testLM.Parent);
                 Assert.IsNotNull(myMediaServer, "DbMediaServer class returned a null reference");
                 Assert.IsInstanceOfType(myMediaServer, typeof(DbMediaServer), "DbMediaServer Instance is not of the correct type");
             }
         }
     }
     TestInfrastructure.DebugLineEnd(TestContext);
 }