Created
June 11, 2016 11:47
-
-
Save farhad-taran/cba9077977b5e7bb2123ddf34f986406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class WhenInitializingCompositionRoot | |
{ | |
public void CheckTypes(params Type[] typesToCheck) | |
{ | |
var settings = new Mock<ISettings>(); | |
settings.Setup(x => x.GetSetting(SettingsKeys.ElasticsearchConnectionString)).Returns("http://dummy.com"); | |
settings.Setup(x => x.GetSetting(SettingsKeys.PaymentsAzureStorageConnectionString)).Returns("DefaultEndpointsProtocol=https;AccountName=fakeaccount;AccountKey=0tsE60UFQfQEZIqCpYJQmN2p11vkfOdEp6a8PSWjJML25v1VJkH5MnpLO1s0iZau7KZAJ0ODa+jRjZGlLjUOfg=="); | |
settings.Setup(x => x.GetSetting(SettingsKeys.NotificationsStorageConnectionString)).Returns("DefaultEndpointsProtocol=https;AccountName=fakeaccount;AccountKey=0tsE60UFQfQEZIqCpYJQmN2p11vkfOdEp6a8PSWjJML25v1VJkH5MnpLO1s0iZau7KZAJ0ODa+jRjZGlLjUOfg=="); | |
var connection = new Mock<IConnectionMultiplexer>(); | |
connection.Setup(x => x.GetDatabase(-1, null)).Returns(new Mock<IDatabase>().Object); | |
var kernel = ParkingApi.CompositionRoot.Initialize(settings.Object, connection.Object, connection.Object, connection.Object); | |
var types = Assembly | |
.GetAssembly(typeof(ParkingApi.CompositionRoot)) | |
.GetTypes() | |
.Where(x => typesToCheck.Any(x.InheritsOrImplements)) | |
.ToArray(); | |
foreach (var item in types) | |
{ | |
Assert.IsNotNull(kernel.GetService(item)); | |
} | |
} | |
[TestMethod] | |
public void ControllerDependenciesAreBound() | |
{ | |
CheckTypes(typeof(Controller), typeof(ApiController)); | |
} | |
[TestMethod] | |
public void MediatrHandlersAreBound() | |
{ | |
CheckTypes(typeof(IRequestHandler<,>), typeof(IAsyncRequestHandler<,>)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment