You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Http;
using Microsoft.AspNetCore.TestHost;
using Xunit;
using Xunit.Abstractions;
using Xunit.Extensions;
using Xunit.Sdk;
namespace ConfigureStudy.Test
{
[Collection("FullFixture")]
public class ConfigTest:IDisposable
{
private TestServer testServer;
private ConfigFixture config;
public ConfigTest(TestServerFixture testServerFixture, ConfigFixture config)
{
this.testServer = testServerFixture.TestServer;
this.config = config;
}
[Fact]
public void DatabaseConnect_Test()
{
var con = config.GetConnectionStringFromJsonConfig();
Assert.Equal("Server=.\\2008; Database=MyDatabase; User ID=sa; Password=gly-bicijinlian; Trusted_Connection=False;", con);
}
[Fact]
public async Task TestServer_Test()
{
var client = testServer.CreateClient();
var responseMessage = await client.GetAsync("/api/values");
Assert.Equal(HttpStatusCode.OK, responseMessage.StatusCode);
}
public void Dispose()
{
}
}
}