Files
cuetools.net/CUETools/CUETools.TestCodecs/ALACWriterTest.cs
Grigory Chudov 9670c6c891 Refactoring codecs infrastructure:
AudioWriterSettings passed to IAdioDest constructors now
AudioWriterSettings now includes AudioPCMConfig
2013-04-07 20:41:58 -04:00

127 lines
3.6 KiB
C#

// The following code was generated by Microsoft Visual Studio 2005.
// The test owner should check each test for validity.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text;
using System.Collections.Generic;
using System.IO;
using CUETools.Codecs;
using CUETools.Codecs.ALAC;
namespace CUETools.TestCodecs
{
/// <summary>
///This is a test class for CUETools.Codecs.ALAC.ALACWriter and is intended
///to contain all CUETools.Codecs.ALAC.ALACWriter Unit Tests
///</summary>
[TestClass()]
public class ALACWriterTest
{
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
/// <summary>
///A test for ALACWriter (string, int, int, int, Stream)
///</summary>
[TestMethod()]
public void ConstructorTest()
{
AudioBuffer buff = WAVReader.ReadAllSamples("test.wav", null);
ALACWriter target;
target = new ALACWriter("alacwriter1.m4a", null, new ALACWriterSettings() { PCM = buff.PCM });
target.Settings.Padding = 1;
target.Vendor = "CUETools";
target.CreationTime = DateTime.Parse("15 Aug 1976");
target.FinalSampleCount = buff.Length;
target.Write(buff);
target.Close();
CollectionAssert.AreEqual(File.ReadAllBytes("alac.m4a"), File.ReadAllBytes("alacwriter1.m4a"), "alacwriter1.m4a doesn't match.");
target = new ALACWriter("alacwriter0.m4a", null, new ALACWriterSettings() { PCM = buff.PCM });
target.Settings.Padding = 1;
target.Vendor = "CUETools";
target.CreationTime = DateTime.Parse("15 Aug 1976");
target.Write(buff);
target.Close();
CollectionAssert.AreEqual(File.ReadAllBytes("alac.m4a"), File.ReadAllBytes("alacwriter0.m4a"), "alacwriter0.m4a doesn't match.");
}
[TestMethod()]
public void SeekTest()
{
var r = new ALACReader("alac.m4a", null);
var buff1 = new AudioBuffer(r, 16536);
var buff2 = new AudioBuffer(r, 16536);
Assert.AreEqual(0, r.Position);
r.Read(buff1, 7);
Assert.AreEqual(7, r.Position);
r.Position = 0;
Assert.AreEqual(0, r.Position);
r.Read(buff2, 7);
Assert.AreEqual(7, r.Position);
AudioBufferTest.AreEqual(buff1, buff2);
r.Read(buff1, 7);
Assert.AreEqual(7 + 7, r.Position);
r.Position = 7;
Assert.AreEqual(7, r.Position);
r.Read(buff2, 7);
Assert.AreEqual(7 + 7, r.Position);
AudioBufferTest.AreEqual(buff1, buff2);
r.Close();
}
}
}