Minimal XMLBackendProvider for testing the loading of an xml file.
Наследование: SIL.FieldWorks.FDO.Infrastructure.Impl.XMLBackendProvider
        public void SlightlyCorruptedXMLFileTest()
        {
            var testDataPath = Path.Combine(DirectoryFinder.FwSourceDirectory, "FDO/FDOTests/TestData");
            var projName     = Path.Combine(testDataPath, "SlightlyCorruptedXMLFile.fwdata");

            // MockXMLBackendProvider implements IDisposable therefore we need the "using".
            // Otherwise the build agent might complain, and in the worst case the test might hang.
            using (var xmlBep = new MockXMLBackendProvider(Cache, projName))
            {
                // Should not throw an XMLException. The code that detects a corrupt file shouldn't
                // care about an extra character or two at the end of the file after the last tag.
                xmlBep.Startup();
            }
        }
        public void CorruptedXMLFileTest()
        {
            var testDataPath = Path.Combine(DirectoryFinder.FwSourceDirectory, "FDO/FDOTests/TestData");
            var projName     = Path.Combine(testDataPath, "CorruptedXMLFileTest.fwdata");

            // MockXMLBackendProvider implements IDisposable therefore we need the "using".
            // Otherwise the build agent might complain, and in the worst case the test might hang.
            using (var xmlBep = new MockXMLBackendProvider(Cache, projName))
            {
                // Should throw an XMLException, but this will be caught and because there's
                // no .bak file, an FwStartupException will be thrown instead.
                xmlBep.Startup();
            }
        }
		public void XMLFileWithDuplicateGuidsTest()
		{
			var testDataPath = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/TestData");
			var projName = Path.Combine(testDataPath, "DuplicateGuids.fwdata");

			// MockXMLBackendProvider implements IDisposable therefore we need the "using".
			// Otherwise the build agent might complain, and in the worst case the test might hang.
			using (var xmlBep = new MockXMLBackendProvider(Cache, projName))
			{
				// Should not throw an XMLException. The code that detects a corrupt file shouldn't
				// care about an extra character or two at the end of the file after the last tag.
				xmlBep.Startup();
				Assert.That(xmlBep.ListOfDuplicateGuids.Count, Is.GreaterThan(0), "The loading of this test project should result in finding duplicate guids.");

				Assert.That(xmlBep.ListOfDuplicateGuids.Contains("cc60cb18-5067-442b-a740-d3b913b2610a, classname: PartOfSpeech"), "The guid cc60cb18-5067-442b-a740-d3b913b2610a should have been found as a duplicate.");
				Assert.That(xmlBep.ListOfDuplicateGuids.Contains("30d07580-5052-4d91-bc24-469b8b2d7df9, classname: PartOfSpeech"), "The guid 30d07580-5052-4d91-bc24-469b8b2d7df9 should have been found as a duplicate.");
				Assert.That(xmlBep.ListOfDuplicateGuids.Contains("6df1c8ee-5530-4180-99e8-be2afab0f60d, classname: PartOfSpeech"), "The guid 6df1c8ee-5530-4180-99e8-be2afab0f60d should have been found as a duplicate.");
				Assert.That(xmlBep.ListOfDuplicateGuids.Contains("a4a759b4-5a10-4d7a-80a3-accf5bd840b1, classname: PartOfSpeech"), "The guid a4a759b4-5a10-4d7a-80a3-accf5bd840b1 should have been found as a duplicate.");
				Assert.That(xmlBep.ListOfDuplicateGuids.Contains("a5311f3b-ff98-47d2-8ece-b1aca03a8bbd, classname: PartOfSpeech"), "The guid a5311f3b-ff98-47d2-8ece-b1aca03a8bbd should have been found as a duplicate.");
				Assert.That(xmlBep.ListOfDuplicateGuids.Contains("f1ac9eab-5f8c-41cf-b234-e53405aaaac5, classname: PartOfSpeech"), "The guid f1ac9eab-5f8c-41cf-b234-e53405aaaac5 should have been found as a duplicate.");
			}
		}
		public void SlightlyCorruptedXMLFileTest()
		{
			var testDataPath = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/TestData");
			var projName = Path.Combine(testDataPath, "SlightlyCorruptedXMLFile.fwdata");

			// MockXMLBackendProvider implements IDisposable therefore we need the "using".
			// Otherwise the build agent might complain, and in the worst case the test might hang.
			using (var xmlBep = new MockXMLBackendProvider(Cache, projName))
			{
				// Should not throw an XMLException. The code that detects a corrupt file shouldn't
				// care about an extra character or two at the end of the file after the last tag.
				xmlBep.Startup();
			}
		}
		public void StartupExtantTest()
		{
			string testFileName = String.Empty;
			try
			{
				var testDataPath = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/BackupRestore/BackupTestProject");
				var projName = Path.Combine(testDataPath, "BackupTestProject.fwdata");
				testFileName = Path.GetTempFileName();
				// If we leave the extension as .tmp, we get a sharing violation when the
				// MockXMLBackendProvider ctor tries to write to the same name with .tmp extension
				testFileName = Path.ChangeExtension(testFileName, "fwdata");
				File.Copy(projName, testFileName, true);

				// MockXMLBackendProvider implements IDisposable therefore we need the "using".
				// Otherwise the build agent might complain, and in the worst case the test might hang.
				using (var xmlBep = new MockXMLBackendProvider(Cache, testFileName))
				{
					// Should throw an UnauthorizedAccessException.
					xmlBep.StartupExtant();
				}
			}
			finally
			{
				File.Delete(testFileName);
			}
		}
		public void CorruptedXMLFileTest()
		{
			var testDataPath = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/TestData");
			var projName = Path.Combine(testDataPath, "CorruptedXMLFileTest.fwdata");

			// MockXMLBackendProvider implements IDisposable therefore we need the "using".
			// Otherwise the build agent might complain, and in the worst case the test might hang.
			using (var xmlBep = new MockXMLBackendProvider(Cache, projName))
			{
				// Should throw an XMLException, but this will be caught and because there's
				// no .bak file, an StartupException will be thrown instead.
				xmlBep.Startup();
			}
		}