﻿using NUnit.Framework;

namespace Virtlink.Vfs
{
	partial class FilenameTests
	{
		/// <summary>
		/// Tests the <see cref="Filename.Root"/> property.
		/// </summary>
		[TestFixture]
		public class RootTests : FilenameTests
		{
			[Test]
			public void IsSameAsRootForRoot()
			{
				// Arrange
				var filename = GetFilename("test:///");

				// Assert
				Assert.That(filename.Root, Is.EqualTo(filename));
			}

			[Test]
			public void IsParentForDirectChild()
			{
				// Arrange
				var filename = GetFilename("test:///foo.zip");

				// Assert
				Assert.That(filename.Root, Is.EqualTo(filename.Parent));
			}

			[Test]
			public void IsRoot()
			{
				// Arrange
				var filename = GetFilename("test:///foo/bar.txt");

				// Assert
				Assert.That(filename.Root.ToString(), Is.EqualTo("test:///"));
			}


			[Test]
			public void IsRootOfCurrentFileSystemInContainer()
			{
				// Arrange
				var filename = GetFilename("test:file:///foo.zip!/bar/");

				// Assert
				Assert.That(filename.Root.ToString(), Is.EqualTo("test:file:///foo.zip!/"));
			}
		}
	}
}
