aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs
blob: 3dd38c8e9b9ecc7e5daf668bf5497d5c5c7ef16b (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
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.IO;
using Tango.SQLExaminer;

namespace Tango.UnitTesting
{
    [TestClass]
    [TestCategory("SQL Examiner")]
    public class SQLExaminer_TST
    {
        [TestMethod]
        public void Generate_Schema_Synchronization_Script()
        {
            ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.Schema);

            var temp_folder = Helper.GetTempFolderPath();

            builder.
                SetSourceServer("localhost\\SQLEXPRESS", "Tango", false, "Synchronizer", "Aa123456").
                SetTargetServer("twine01\\SQLTWINE", "Tango").
                SetBackupFile(Path.Combine(temp_folder, "db.bak")).
                SetReportFile(Path.Combine(temp_folder, "report.xml"));

            var config = builder.Build();

            String config_path = Path.Combine(temp_folder, "schema.xml");

            config.ToFile(config_path);

            Helper.ShowInExplorer(config_path);
        }

        [TestMethod]
        public void Generate_Provisioning_Synchronization_Script()
        {
            ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.ProvisionMachine);

            var temp_folder = Helper.GetTempFolderPath();

            builder.
                SetSourceServer("localhost\\SQLEXPRESS", "Tango", false, "Synchronizer", "Aa123456").
                SetTargetServer("twine01\\SQLTWINE", "Tango").
                SetReportFile(Path.Combine(temp_folder, "report.xml")).
                SetMachineSerialNumber("1111");

            var config = builder.Build();

            String config_path = Path.Combine(temp_folder, "provision.xml");

            config.ToFile(config_path);

            Helper.ShowInExplorer(config_path);
        }

        [TestMethod]
        public void Generate_Data_Overriding_Script()
        {
            ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.OverrideData);

            var temp_folder = Helper.GetTempFolderPath();

            builder.
                SetSourceServer("localhost\\SQLEXPRESS", "Tango", false, "Synchronizer", "Aa123456").
                SetTargetServer("twine01\\SQLTWINE", "Tango").
                SetReportFile(Path.Combine(temp_folder, "report.xml"));

            var config = builder.Build();

            String config_path = Path.Combine(temp_folder, "data.xml");

            config.ToFile(config_path);

            Helper.ShowInExplorer(config_path);
        }

        [TestMethod]
        public void Synchronize_Schema()
        {
            ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.Schema);

            var temp_folder = Helper.GetTempFolderPath();

            builder.
                SetSourceServer("localhost\\SQLEXPRESS", "Tango").
                SetTargetServer("localhost\\SQLEXPRESS", "Test").
                SetBackupFile(Path.Combine(temp_folder, "db.bak")).
                SetReportFile(Path.Combine(temp_folder, "report.xml"));

            var config = builder.Build();

            String config_path = Path.Combine(temp_folder, "schema.xml");

            config.ToFile(config_path);

            Helper.ShowInExplorer(config_path);
        }
    }
}