NucuCar/NucuCar.UnitTests/NucuCar.Domain.Tests/Utilities/ConnectionStringParserTest.cs

51 lines
No EOL
1.6 KiB
C#

using System;
using System.Collections.Generic;
using NucuCar.Domain.Utilities;
using Xunit;
namespace NucuCar.UnitTests.NucuCar.Domain.Tests.Utilities
{
public class ConnectionStringParserTest
{
[Fact]
private void Test_ConnectionStringParser_Valid()
{
const string connectionString = "Test=1;Test2=2";
var parsedString = ConnectionStringParser.Parse(connectionString);
Assert.Equal("1", parsedString.GetValueOrDefault("Test"));
Assert.Equal("2", parsedString.GetValueOrDefault("Test2"));
}
[Fact]
private void Test_ConnectionStringParser_EmptyValue()
{
const string connectionString = "Test=1;Test2=";
var parsedString = ConnectionStringParser.Parse(connectionString);
Assert.Equal("1", parsedString.GetValueOrDefault("Test"));
Assert.Equal(string.Empty, parsedString.GetValueOrDefault("Test2"));
}
[Fact]
private void Test_ConnectionStringParser_EmptyValue2()
{
Assert.Throws<ArgumentException>(() =>
{
ConnectionStringParser.Parse(string.Empty);
});
}
[Fact]
private void Test_ConnectionStringParser_Invalid()
{
const string connectionString = "Test=1;Test2=;d";
Assert.Throws<ArgumentException>(() =>
{
ConnectionStringParser.Parse(connectionString);
});
}
}
}