This repository has been archived by the owner on Dec 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestConnectionMSSQL.cs
50 lines (45 loc) · 1.62 KB
/
TestConnectionMSSQL.cs
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
using KD.FakeDb.Connection.MSSQL;
using KD.FakeDb.Factory;
using KD.FakeDb.Serialization;
using KD.FakeDb.Serialization.XML;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Xml;
using Xunit;
namespace KD.FakeDb.XUnitTests.Connection
{
public class TestConnectionMSSQL
{
[Fact]
public void Test_if_database_was_mapped_to_Fake_and_saved_in_XML()
{
// Test for SQL Server 13.0.4422.0
var dbConn = new DatabaseConnectionMSSQL()
{
Database = FakeDatabaseFactory.NewDatabase("Name_which_will_be_replaced_after_mapping"),
Connection = new SqlConnection()
{
ConnectionString = $"" +
$"Server=mssql6.gear.host;" +
$"Database=testdb49;" +
$"User Id=testdb49;" +
$"Password=;"
}
};
dbConn.ToFake("testdb49"); // This weird name is an actual Database Name
var fakeDb = dbConn.Database;
var fileStream = new FileStream("db_mssql.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
using (var writer = XmlWriter.Create(fileStream))
{
var serializer = new FakeDbSerializer<XmlReader, XmlWriter>()
{
Database = fakeDb,
Configuration = new FakeDbXMLByColumnConfiguration()
};
serializer.WriteDatabase(writer);
}
Assert.True(fakeDb.Tables.Count() > 0);
}
}
}