// 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 { /// ///This is a test class for CUETools.Codecs.ALAC.ALACWriter and is intended ///to contain all CUETools.Codecs.ALAC.ALACWriter Unit Tests /// [TestClass()] public class ALACWriterTest { private TestContext testContextInstance; /// ///Gets or sets the test context which provides ///information about and functionality for the current test run. /// 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 /// ///A test for ALACWriter (string, int, int, int, Stream) /// [TestMethod()] public void ConstructorTest() { AudioBuffer buff = WAVReader.ReadAllSamples("test.wav", null); ALACWriter target; ALACWriter.Vendor = "CUETools"; target = new ALACWriter("alacwriter1.m4a", null, new ALACWriterSettings() { PCM = buff.PCM }); target.Settings.Padding = 1; 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.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(); } } }