public async Task GET_ReturnsJsonResult_OnValidBridgeResponse() { var providerMock = new Mock <IGeocodingProvider>(MockBehavior.Strict); providerMock.Setup(provider => provider.ReverseGeocoding(It.IsAny <IPoint>())) .ReturnsAsync("location"); var loggerStub = new Mock <ILogger <GeocodingController> >(MockBehavior.Loose); var controller = new GeocodingController(providerMock.Object, loggerStub.Object); var result = await controller.Get(0, 0); Assert.IsType <JsonResult>(result); }
public async Task Test1() { Assert.True(true); return; var providerMock = new Mock <IGeocodingProvider>(); providerMock.Setup(provider => provider.ReverseGeocoding(It.IsAny <Point>())) .ReturnsAsync("location"); var controller = new GeocodingController(providerMock.Object); var result = await controller.Get(0, 0); //Assert.IsInstanceOf<JsonResult>(result); Assert.True(true); }
public async Task GET_Returns422_OnApiProviderError() { var providerMock = new Mock <IGeocodingProvider>(MockBehavior.Strict); providerMock.Setup(provider => provider.ReverseGeocoding(It.IsAny <IPoint>())) .Throws <ApiException>(); var loggerStub = new Mock <ILogger <GeocodingController> >(MockBehavior.Loose); var controller = new GeocodingController(providerMock.Object, loggerStub.Object); var result = await controller.Get(0, 0); Assert.IsType <ObjectResult>(result); var jsonResult = (ObjectResult)result; Assert.Equal(422, jsonResult.StatusCode); }
public async Task GET_ReturnsValidLocationViewModel_OnValidBridgeResponse() { var providerMock = new Mock <IGeocodingProvider>(MockBehavior.Strict); providerMock.Setup(provider => provider.ReverseGeocoding(It.IsAny <IPoint>())) .ReturnsAsync("location"); var loggerStub = new Mock <ILogger <GeocodingController> >(MockBehavior.Loose); var controller = new GeocodingController(providerMock.Object, loggerStub.Object); var result = await controller.Get(0, 0); JsonResult jsonResult = (JsonResult)result; Assert.IsType <LocationViewModel>(jsonResult.Value); LocationViewModel viewModel = (LocationViewModel)jsonResult.Value; Assert.Equal("location", viewModel.Location); }