55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
using System.Threading.Tasks;
|
|
using Newtonsoft.Json;
|
|
using Xunit;
|
|
using Landmark.OLA.Application.Common.Domain;
|
|
using Landmark.OLA.Models.Loan;
|
|
|
|
namespace Landmark.OLA.Integration.Tests
|
|
{
|
|
|
|
public class UISettingsControllerTest : OlaIntegrationTest
|
|
{
|
|
private readonly BranchConfig _branchConfig;
|
|
private readonly BranchNameConfig _branchNameConfig;
|
|
private readonly StoredSettings _storedSettings;
|
|
|
|
public UISettingsControllerTest() : base()
|
|
{
|
|
_branchConfig = new BranchConfig
|
|
{
|
|
Id = "012345678901234567890123456789012345"
|
|
};
|
|
_branchNameConfig = new BranchNameConfig
|
|
{
|
|
Id = "912345678901234567890123456789012345"
|
|
};
|
|
_storedSettings = new StoredSettings
|
|
{
|
|
Id = "123456789012345678901234567890123456"
|
|
};
|
|
|
|
mockBranchDataAccess.Setup(repo => repo.GetBranchConfig()).Returns(_branchConfig);
|
|
mockBranchDataAccess.Setup(repo => repo.GetBranchNameConfig()).Returns(_branchNameConfig);
|
|
mockConfigurationAccess.Setup(repo => repo.GetStoredSettings()).Returns(_storedSettings);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task CanGetSettings()
|
|
{
|
|
// The endpoint or route of the controller action.
|
|
var httpResponse = await _client.GetAsync("/api/UISettings");
|
|
|
|
// Must be successful.
|
|
httpResponse.EnsureSuccessStatusCode();
|
|
|
|
// Deserialize and examine results.
|
|
var stringResponse = await httpResponse.Content.ReadAsStringAsync();
|
|
var settings = JsonConvert.DeserializeObject<UiSettings>(stringResponse);
|
|
Assert.NotNull(settings.BranchMapping);
|
|
Assert.NotNull(settings.BranchNameMapping);
|
|
Assert.Equal(_branchConfig.Id, settings.BranchMapping.Id);
|
|
Assert.Equal(_branchNameConfig.Id, settings.BranchNameMapping.Id);
|
|
}
|
|
}
|
|
}
|