public async Task GetValueAsyncTest()
		{
			TrackExposer exposer = new TrackExposer();
			exposer.GetValues["TEST"] = "This is my Test";
			exposer.GetValues["TEST2"] = "Another Test";
			exposer.GetValues["TITLE"] = "Title value";

			var disk = new DiskExposer();
			exposer.Disk = disk;
			disk.GetValues["DISKTITLE"] = "This is the disk title";
			disk.GetValues["TITLE"] = "This is not the title we want.";

			var config = disk.GetConfiguration as ConfigurationExposer;
			config.GetValues["CONFIGTITLE"] = "This is the Config Title";
			config.GetValues["DESCRIPTION"] = "This is the Description";
			config.GetValues["TEST"] = "This is not the test we want.";

			Assert.AreEqual<String>("This is my Test", await exposer.GetValueAsync("test"), "Test value does not match");
			Assert.AreEqual<String>("Another Test", await exposer.GetValueAsync("test2"), "Test2 value does not match");
			Assert.AreEqual<String>("Title value", await exposer.GetValueAsync("title"), "Title value does not match");
			Assert.AreEqual<String>("This is the disk title", await exposer.GetValueAsync("disktitle"), "DiskTitle value does not match");
			Assert.AreEqual<String>("This is the Config Title", await exposer.GetValueAsync("configtitle"), "ConfigTitle value does not match");
			Assert.AreEqual<String>("This is the Description", await exposer.GetValueAsync("description"), "Description value does not match");
			Assert.IsNull(await exposer.GetValueAsync("cheese"), "cheese value was suppose to be null and was not");
		}
		public async Task LoadTrackAsyncTest()
		{
			XElement trackXML = new XElement("Track",
				new XAttribute("template", "Template.xml"),
				new XAttribute("song", "Itsy Bitsy Spider"),
				new XElement("Name", "This is the name"),
				new XElement("Description", "Description of the show"),
				new XElement("Cheese", "Cheddar"));
			
			FileInfo template = new FileInfo("Template.xml");
			using (StreamWriter writer = new StreamWriter(template.Open(FileMode.Create)))
			{
				await writer.WriteAsync(
@"
<Template templateId=""2"">
	<Name>This name is going to be overridden</Name>
	<Year>2008</Year>
	<Color>Green</Color>
</Template>
");
			}

			TrackExposer track = new TrackExposer();

			AssertHelpers.ThrowsException<ArgumentNullException>(() =>
				{
					track.LoadTrackAsync(null, Path.GetFullPath("Disk.xml")).GetAwaiter().GetResult();
				});

			AssertHelpers.ThrowsException<ArgumentNullException>(() =>
				{
					track.LoadTrackAsync(trackXML, null).GetAwaiter().GetResult();
				});

			var status = await track.LoadTrackAsync(trackXML, Path.GetFullPath("Disk.xml"));

			Assert.IsTrue(status, "Status was not true and should have been.");
			var values = track.GetValues;
			Assert.IsNotNull(values, "Values was null and should not have been.");
			Assert.IsTrue(values.ContainsKey("SONG"), "Song was not found.");
			Assert.AreEqual<String>("Itsy Bitsy Spider", values["SONG"], "Song value did not match.");
			Assert.IsTrue(values.ContainsKey("NAME"), "Name was not found.");
			Assert.AreEqual<String>("This is the name", values["NAME"], "Name value did not match.");
			Assert.IsTrue(values.ContainsKey("DESCRIPTION"), "Description was not found");
			Assert.AreEqual<String>("Description of the show", values["DESCRIPTION"], "Description value did not match");
			Assert.IsTrue(values.ContainsKey("CHEESE"), "Cheese was not found.");
			Assert.AreEqual<String>("Cheddar", values["CHEESE"], "Cheese value did not match.");
			Assert.IsTrue(values.ContainsKey("TEMPLATEID"), "TemplateId was not found");
			Assert.AreEqual<String>("2", values["TEMPLATEID"], "TemplateId did not match");
			Assert.IsTrue(values.ContainsKey("YEAR"), "Year was not found.");
			Assert.AreEqual<String>("2008", values["YEAR"], "Year value did not match");
			Assert.IsTrue(values.ContainsKey("COLOR"), "Color was not found.");
			Assert.AreEqual<String>("Green", values["COLOR"], "Color value did not match");
		}
		public void FixFileNameTest()
		{
			AssertHelpers.ThrowsException<ArgumentNullException>(() => { Methods.FixFileName(null, "test"); });
			
			TrackExposer track = new TrackExposer();
			track.GetValues["TEST"] = "Hi";
			track.GetValues["NAME"] = "Into, the \"Wild\", Green Yonder.mp4";

			Assert.AreEqual("", Methods.FixFileName(track), "Return value was not correct for no arguments");
			Assert.AreEqual("Into, the _Wild_, Green Yonder.mp4", Methods.FixFileName(track, "name"), "Name value was not transformed correctly.");
			Assert.AreEqual("Into, the _Wild_, Green Yonder.mp4", Methods.FixFileName(track, "name", "Description"), "Name value was not transformed correctly.");
		}
        public void GetFileExtTest()
        {
            HandBrakeEncoder encoder = new HandBrakeEncoder();
            TrackExposer track = new TrackExposer();

            AssertHelpers.ThrowsException<ArgumentNullException>(() => { encoder.GetFileExt(null); });

            var actual = encoder.GetFileExt(track);
            Assert.AreEqual(".mp4", actual, "HandBrakeEncoder did not return the correct default fileExtension");
            track.GetValues["FILENAME"] = "Test.m4v";
            actual = encoder.GetFileExt(track);
            Assert.AreEqual(".m4v", actual, "HandBrakeEncoder did not return the fileExtension of property FILENAME");
            track.GetValues["FILEEXT"] = ".mp3";
            actual = encoder.GetFileExt(track);
            Assert.AreEqual(".mp3", actual, "HandBrakeEncoder did not return the fileExtension of property FILEEXT");
            track.GetValues["HBFILEEXT"] = ".mkv";
            actual = encoder.GetFileExt(track);
            Assert.AreEqual(".mkv", actual, "HandBrakeEncoder did not return the fileExtension of property HBFILEEXT");
        }
        public void GenerateArguments()
        {
            HandBrakeEncoderExposer encoder = new HandBrakeEncoderExposer();
            TrackExposer track = new TrackExposer();
            String tmpFilePath = "/tmp/File01.mp4";

            AssertHelpers.ThrowsException<ArgumentNullException>(() => { encoder.GenerateArgumentsExposed(null, track); });
            AssertHelpers.ThrowsException<ArgumentNullException>(() => { encoder.GenerateArgumentsExposed(tmpFilePath, null); });

            var actual = encoder.GenerateArgumentsExposed(tmpFilePath, track);
            Assert.AreEqual("-o \"/tmp/File01.mp4\" ", actual);
            track.GetValues["HANDBRAKEOPTIONS"] = "-e x264 -q 20 -X 720 -a 1 -B 160 -R 48 -6 dpl2 -D 1.0 -2 -T -E faac --loose-anamorphic  -f mp4 --decomb -m -x b-adapt=2:rc-lookahead=50";

            actual = encoder.GenerateArgumentsExposed(tmpFilePath, track);
            Assert.AreEqual("-o \"/tmp/File01.mp4\" -e x264 -q 20 -X 720 -a 1 -B 160 -R 48 -6 dpl2 -D 1.0 -2 -T -E faac --loose-anamorphic  -f mp4 --decomb -m -x b-adapt=2:rc-lookahead=50", actual, "Unexpected arguments returned.");
            track.GetValues["TITLECHAPTER"] = "-t 1 -c 5-8";

            actual = encoder.GenerateArgumentsExposed(tmpFilePath, track);
            Assert.AreEqual("-t 1 -c 5-8 -o \"/tmp/File01.mp4\" -e x264 -q 20 -X 720 -a 1 -B 160 -R 48 -6 dpl2 -D 1.0 -2 -T -E faac --loose-anamorphic  -f mp4 --decomb -m -x b-adapt=2:rc-lookahead=50", actual);
            track.GetValues["INPUTPATH"] = "/dev/dvd";

            actual = encoder.GenerateArgumentsExposed(tmpFilePath, track);
            Assert.AreEqual("-i \"/dev/dvd\" -t 1 -c 5-8 -o \"/tmp/File01.mp4\" -e x264 -q 20 -X 720 -a 1 -B 160 -R 48 -6 dpl2 -D 1.0 -2 -T -E faac --loose-anamorphic  -f mp4 --decomb -m -x b-adapt=2:rc-lookahead=50", actual);
        }
		public async Task ResolveFormatAndMethods()
		{
			await Methods.LoadVariableMethods();
			TrackExposer exposer = new TrackExposer();
			exposer.GetValues["TEST"] = "23.4";
			exposer.GetValues["TEST2"] = "6";
			exposer.GetValues["CHEESE"] = "Cheddar";
			exposer.GetValues["SHOWNAME"] = "Future";
			exposer.GetValues["FILENAME"] = "Into, the \"Wild\", Green Yonder.mp4";

			var results = exposer.ResolveFormatAndMethodsPublic("${Test:000.000}");
			Assert.AreEqual("023.400", results, "double test");
			results = exposer.ResolveFormatAndMethodsPublic("${Test2:000}");
			Assert.AreEqual("006", results, "long test");
			results = exposer.ResolveFormatAndMethodsPublic("${SHOWNAME} ${Cheese}");
			Assert.AreEqual("Future Cheddar", results, "String Combine");
			results = exposer.ResolveFormatAndMethodsPublic("${Test2} %{FixFileName(FileName)}");
			Assert.AreEqual("6 Into, the _Wild_, Green Yonder.mp4", results, "Method call");
		}