2021-08-03 09:04:49 +02:00
|
|
|
// Copyright (c) Umbraco.
|
2020-12-20 08:36:11 +01:00
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Configuration;
|
|
|
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
|
|
|
using Constants = Umbraco.Cms.Core.Constants;
|
2020-03-23 14:31:21 +01:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Configuration.Models
|
2020-03-23 14:31:21 +01:00
|
|
|
{
|
|
|
|
|
public class ConnectionStringsTests
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
[TestCase("", ExpectedResult = null)]
|
|
|
|
|
[TestCase(null, ExpectedResult = null)]
|
|
|
|
|
[TestCase(@"Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1;", ExpectedResult = Constants.DbProviderNames.SqlCe)]
|
|
|
|
|
[TestCase(@"Server=(LocalDb)\Umbraco;Database=NetCore;Integrated Security=true", ExpectedResult = Constants.DbProviderNames.SqlServer)]
|
2021-08-03 09:04:49 +02:00
|
|
|
[TestCase(@"Data Source=(LocalDb)\Umbraco;Initial Catalog=NetCore;Integrated Security=true;", ExpectedResult = Constants.DbProviderNames.SqlServer)]
|
|
|
|
|
[TestCase(@"Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=MyDataFile.mdf;", ExpectedResult = Constants.DbProviderNames.SqlServer)]
|
2020-03-23 14:31:21 +01:00
|
|
|
public string ParseProviderName(string connectionString)
|
|
|
|
|
{
|
2020-09-11 21:13:18 +02:00
|
|
|
var connectionStrings = new ConnectionStrings
|
2020-03-23 14:31:21 +01:00
|
|
|
{
|
2020-09-15 09:11:36 +02:00
|
|
|
UmbracoConnectionString = new ConfigConnectionString(Constants.System.UmbracoConnectionName, connectionString)
|
2020-09-11 21:13:18 +02:00
|
|
|
};
|
2020-03-23 14:31:21 +01:00
|
|
|
|
2020-09-15 09:11:36 +02:00
|
|
|
var actual = connectionStrings.UmbracoConnectionString;
|
2020-03-23 14:31:21 +01:00
|
|
|
|
|
|
|
|
Assert.AreEqual(connectionString, actual.ConnectionString);
|
2020-09-15 09:11:36 +02:00
|
|
|
Assert.AreEqual(Constants.System.UmbracoConnectionName, actual.Name);
|
2020-03-23 14:31:21 +01:00
|
|
|
|
2020-09-15 09:11:36 +02:00
|
|
|
return connectionStrings.UmbracoConnectionString.ProviderName;
|
2020-03-23 14:31:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|