MediaListTests.cs 1.16 KB
Newer Older
1 2
using System;
using System.IO;
Martin Finkel's avatar
Martin Finkel committed
3
using LibVLCSharp.Shared;
4 5
using NUnit.Framework;

6
namespace LibVLCSharp.Tests
7 8
{
    [TestFixture]
9
    public class MediaListTests : BaseSetup
10 11 12 13
    {
        [Test]
        public void AddAndRemoveMediaFromMediaList()
        {
Martin Finkel's avatar
Martin Finkel committed
14 15
            var mediaList = new MediaList(_libVLC);
            var media = new Media(_libVLC, Path.GetTempFileName());
16 17
            var itemAdded = false;
            var itemDeleted = false;
Martin Finkel's avatar
Martin Finkel committed
18 19
            mediaList.ItemAdded += (sender, args) => itemAdded = true;
            mediaList.ItemDeleted += (sender, args) => itemDeleted = true;
20 21 22 23 24 25 26 27 28
            mediaList.AddMedia(media);
            Assert.AreEqual(media, mediaList[0]);
            Assert.AreEqual(1, mediaList.Count);
            Assert.True(itemAdded);
            Assert.Zero(mediaList.IndexOf(media));
            mediaList.RemoveIndex(0);
            Assert.Zero(mediaList.Count);
            Assert.True(itemDeleted);
        }
29 30 31 32

        [Test]
        public void DisposeMediaList()
        {
Martin Finkel's avatar
Martin Finkel committed
33
            var mediaList = new MediaList(_libVLC);
34 35 36
            mediaList.Dispose();
            Assert.AreEqual(IntPtr.Zero, mediaList.NativeReference);
        }
37 38
    }
}