Fixing coverage - 11
This commit is contained in:
45
MainProject.Tests/Controllers/RootController_Tests.cs
Normal file
45
MainProject.Tests/Controllers/RootController_Tests.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using BasicDotnetTemplate.MainProject;
|
||||
using BasicDotnetTemplate.MainProject.Controllers;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using BasicDotnetTemplate.MainProject.Models.Api.Response;
|
||||
using BasicDotnetTemplate.MainProject.Models.Settings;
|
||||
|
||||
|
||||
namespace BasicDotnetTemplate.MainProject.Tests;
|
||||
|
||||
[TestClass]
|
||||
public class RootController_Test
|
||||
{
|
||||
[TestMethod]
|
||||
public void GetRoot_Valid()
|
||||
{
|
||||
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
|
||||
|
||||
try
|
||||
{
|
||||
RootController rootController = new RootController();
|
||||
var result = rootController.GetRoot();
|
||||
if (result != null)
|
||||
{
|
||||
var data = (OkResult)result;
|
||||
Assert.IsTrue(data.StatusCode == 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail($"Data is null");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.InnerException);
|
||||
Assert.Fail($"An exception was thrown: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user