using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using remote = Tango.DAL.Remote.DB; using local = Tango.DAL.Local.DB; using Tango.Synchronization.Remote; using Tango.Settings; using Tango.Core; namespace Tango.UnitTesting { [TestClass] [TestCategory("Synchronization")] public class Synchronization_TST { [TestMethod] public void Compare_Remote_And_Local() { var console = Helper.InitializeLogging(true); using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { using (var localDB = new local.LocalDB(Helper.GetSQLiteFilePath())) { RemoteDBComparer comparer = new RemoteDBComparer(remoteDB, localDB, "1111"); var diffs = comparer.Compare(); } } console.WaitForConsoleExit().Wait(); } [TestMethod] public void Synchronize_Remote_And_Local() { var console = Helper.InitializeLogging(true); RemoteDBSynchronizer.Synchronize(Helper.GetSQLiteFilePath(), "1111", true); console.WaitForConsoleExit().Wait(); } [TestMethod] public void Generate_Demo_Remote_Machine() { using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { var organization = new remote.ORGANIZATION() { ADDRESS = new remote.ADDRESS() { LAST_UPDATED = DateTime.UtcNow, GUID = Guid.NewGuid().ToString(), ADDRESS_STRING = "Demo Address", CITY = "Gan Yavne", COUNTRY = "Israel", COUNTRY_CODE = "IL", LOCALITY = "Local", POSTAL_CODE = "70800", STATE = "Hadarom", }, CONTACT = new remote.CONTACT() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow, EMAIL = "roy.mail.net@gmail.com", FAX = "1234", FIRST_NAME = "Roy", FULL_NAME = "Roy Ben Shabat", LAST_NAME = "Ben Shabat", PHONE_NUMBER = "1234" }, NAME = "Twine Demo", GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow, }; var configuration = new remote.CONFIGURATION() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow, APPLICATION_DISPLAY_PANEL_VERSIONS = new remote.APPLICATION_DISPLAY_PANEL_VERSIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow }, APPLICATION_FIRMWARE_VERSIONS = new remote.APPLICATION_FIRMWARE_VERSIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow }, APPLICATION_OS_VERSIONS = new remote.APPLICATION_OS_VERSIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow }, APPLICATION_VERSIONS = new remote.APPLICATION_VERSIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow }, CREATION_DATE = DateTime.UtcNow, EMBEDDED_FIRMWARE_VERSIONS = new remote.EMBEDDED_FIRMWARE_VERSIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow }, EMBEDDED_SOFTWARE_VERSIONS = new remote.EMBEDDED_SOFTWARE_VERSIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow }, HARDWARE_VERSIONS = new remote.HARDWARE_VERSIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow }, }; var machine_version = new remote.MACHINE_VERSIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow, VERSION = 1.0, }; var machine = new remote.MACHINE() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow, ORGANIZATION = organization, PRODUCTION_DATE = DateTime.UtcNow, SERIAL_NUMBER = "1234", MACHINE_VERSIONS = machine_version, }; var machine_configuration = new remote.MACHINES_CONFIGURATIONS() { GUID = Guid.NewGuid().ToString(), LAST_UPDATED = DateTime.UtcNow, CONFIGURATION = configuration, MACHINE = machine, }; remoteDB.MACHINES.Add(machine); remoteDB.MACHINES_CONFIGURATIONS.Add(machine_configuration); remoteDB.SaveChanges(); } } } }