public void Put_DestinationNull() { string fileContents = string.Format("heading1,date,heading3\ncol1,{0:d},column3\n", DateTime.Now); byte[] data = FilePathDelivery.ConvertToSource(fileContents); DeliveryStrategy target = new FilePathDelivery { Source = data }; target.Put(); Assert.Fail("A NULL Destination did not throw the expected Exception"); }
public void Put_Ignore() { string fileContents = string.Format("heading1,date,heading3\ncol1,{0:d},column3\n", DateTime.Now); byte[] data = FilePathDelivery.ConvertToSource(fileContents); string outputFile = Path.Combine(_outputFolder, "TestPut.csv"); DeliveryStrategy target = new FilePathDelivery { Source = data, Destination = outputFile }; CreateFile(outputFile, "Created by unit test."); bool result = target.Put(DeliveryWriteMode.Ignore); Assert.IsFalse(result, "Did not skip writing when file exists: '{0}'", outputFile); }
public void Put_Exception() { string fileContents = string.Format("heading1,date,heading3\ncol1,{0:d},column3\n", DateTime.Now); byte[] data = FilePathDelivery.ConvertToSource(fileContents); string outputFile = Path.Combine(_outputFolder, "TestPut.csv"); DeliveryStrategy target = new FilePathDelivery { Source = data, Destination = outputFile }; CreateFile(outputFile, "Created by unit test."); target.Put(DeliveryWriteMode.Exception); Assert.Fail("Did not throw expected Exception"); }
public void Put_Overwrite() { string fileContents = string.Format("heading1,date,heading3\ncol1,{0:d},column3\n", DateTime.Now); byte[] data = FilePathDelivery.ConvertToSource(fileContents); string outputFile = Path.Combine(_outputFolder, "TestPut.csv"); DeliveryStrategy target = new FilePathDelivery { Source = data, Destination = outputFile }; bool result = target.Put(DeliveryWriteMode.Overwrite); Assert.IsTrue(result, "Saving file failed: '{0}'", outputFile); string actual = ReadFromFile(outputFile); Assert.AreEqual(fileContents, actual); }
public void Put_InvalidDestinationPath() { string fileContents = string.Format("heading1,date,heading3\ncol1,{0:d},column3\n", DateTime.Now); byte[] data = FilePathDelivery.ConvertToSource(fileContents); DeliveryStrategy target = new FilePathDelivery { Source = data, Destination = @"t:\destination\does\not\exist" }; target.Put(); Assert.Fail("An invalid Destination did not throw the expected Exception"); }