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

51 lines
1.6 KiB
C#
Raw Normal View History

2019-12-19 20:50:51 +00:00
using System;
using System.Collections.Generic;
2019-12-23 22:23:56 +00:00
using NucuCar.Domain.Utilities;
2019-12-19 20:50:51 +00:00
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);
});
}
}
}