aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting/Synchronization_TST.cs
blob: 3b949cf90bd8d033c2061b80df69e25df6727bed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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;

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.DataBase.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.DataBase.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();
            }
        }
    }
}