Exemple #1
0
        public void Test_LoadEntityFromFile()
        {
            TestUser user = new TestUser();

            user.ID        = Guid.NewGuid();
            user.FirstName = "Test";
            user.LastName  = "Test";

            DataExporter exporter = (DataExporter)DataAccess.Data.InitializeDataExporter();

            exporter.ExportDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Exported";

            // Export the user to XML
            exporter.ExportEntity(user);

            string filePath = exporter.CreateEntityPath(user);

            DataImporter importer = (DataImporter)DataAccess.Data.InitializeDataImporter();

            importer.ImportedDirectoryPath = TestUtilities.GetTestingPath(this) + Path.DirectorySeparatorChar + "Imported";

            TestUser foundUser = (TestUser)importer.LoadEntityFromFile(filePath);

            Assert.IsNotNull(foundUser, "foundUser == null");

            Assert.AreEqual(user.ID.ToString(), foundUser.ID.ToString(), "The ID of the found user doesn't have the same ID as the original.");
        }