Skip to content

Instantly share code, notes, and snippets.

@kurtmkurtm
Created July 4, 2019 10:45
Show Gist options
  • Save kurtmkurtm/900120c7b505fcc9bbc579e24f4eeebb to your computer and use it in GitHub Desktop.
Save kurtmkurtm/900120c7b505fcc9bbc579e24f4eeebb to your computer and use it in GitHub Desktop.
xUnit - UserFact Test Sample
using System;
using System.Data;
using Xunit;
using Xunit.UserContext;
using System.Data.SqlClient;
namespace medium
{
public class UnitTest1
{
[UserFact(userSecretsId: "MyTestId")]
public void Test1()
{
var connectionState = ConnectionState.Closed;
var connectionString = @"Data Source=localhost\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=Test;";
using (var connection = new SqlConnection(connectionString))
{
connection.Open();
connectionState = connection.State;
}
Assert.Equal(ConnectionState.Open, connectionState);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment