public async void DeleteResource_InternalServerErrorStatusCode_ThrowsException() { // Arrange var httpService = new Mock <IHttpService>(); var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent("") }; httpService .Setup(m => m.DeleteAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); var scenarioClient = new ScenarioClient( httpService.Object ); Exception exception = null; try { // Act await scenarioClient.DeleteResource( DependantResourceDataMocks.MockDependantResourceModel() ); } catch (FailedToDeleteResourceException e) { exception = e; } // Assert Assert.NotNull(exception); }
public async void UnmarkScenario_MarkedScenarioModel_NoExceptionThrown() { // Assert var dependantResourceModel = new DependantResourceModel( ResourceTypeEnum.Scenario, "aad965db-fceb-4ee2-bd06-c89ab182ca4c" ); var httpService = new HttpService(new HttpClient()); var scenarioClient = new ScenarioClient( httpService ); Exception exception = null; try { // Act await scenarioClient.UnmarkScenario(dependantResourceModel); } catch (Exception e) { exception = e; } // Assert Assert.Null(exception); }
public async void UnmarkScenario_NotFoundStatusCode_NoExceptionThrown() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Some error!") }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <ScenarioModel>())) .ReturnsAsync(httpResponseMessage); var scenarioClient = new ScenarioClient(httpService.Object); Exception exception = null; try { // Act await scenarioClient.UnmarkScenario(DependantResourceDataMocks.MockDependantResourceModel()); } catch (Exception e) { exception = e; } // Assert Assert.Null(exception); }
public async void MarkScenario_MarkedScenarioModel_ThrowsException() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(ScenarioModelDataMocks.MockMarkedScenarioModelJson) }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); var scenarioClient = new ScenarioClient(httpService.Object); Exception exception = null; try { // Act await scenarioClient.MarkScenario(It.IsAny <string>()); } catch (ResourceAlreadyMarkedException e) { exception = e; } // Assert Assert.NotNull(exception); }
public async void DeleteResource_ValidScenarioId_NoExceptionThrown() { // Arrange var dependantResourceModel = new DependantResourceModel { ResourceType = ResourceTypeEnum.Scenario, ResourceId = "6aad965db-fceb-4ee2-bd06-c89ab182ca4c" }; var httpService = new HttpService(new HttpClient()); var scenarioClient = new ScenarioClient(httpService); Exception exception = null; try { // Act await scenarioClient.DeleteResource(dependantResourceModel); } catch (Exception e) { exception = e; } // Assert Assert.Null(exception); }
public async void MarkScenario_UnmarkedScenarioModel_ReturnsDependantResourceModel() { // Assert var scenarioId = "ae7b7512-4233-476b-b3d7-6651aeae6518"; var httpService = new HttpService(new HttpClient()); var scenarioClient = new ScenarioClient( httpService ); // Act var result = await scenarioClient.MarkScenario(scenarioId); // Assert Assert.NotNull(result); }
public async void GetScenariosForProject_ValidProjectId_ReturnsScenarioModelList() { // Assert var projectId = "623be379-ed40-49f3-bdd8-416f8cd0faa6"; var httpService = new HttpService(new HttpClient()); var scenarioClient = new ScenarioClient( httpService ); // Act var result = await scenarioClient.GetScenariosForProject(projectId); // Assert Assert.NotEmpty(result); }
public async void GetScenario_ValidScenarioId_ReturnsScenarioModel() { // Assert var scenarioId = "6c40eb45-1e21-435e-81c8-895e55c6c5d8"; var httpService = new HttpService(new HttpClient()); var scenarioClient = new ScenarioClient( httpService ); // Act var result = await scenarioClient.GetScenario(scenarioId); // Assert Assert.NotNull(result); }
public async void GetScenariosForMetadata_OkStatusCode_ReturnsScenarioModelList() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(ScenarioModelDataMocks.MockScenarioModelListJson) }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); var scenarioClient = new ScenarioClient(httpService.Object); // Act var result = await scenarioClient.GetScenariosForMetadata(It.IsAny <string>()); // Assert Assert.NotEmpty(result); }
public async void MarkScenario_ScenarioModel_ReturnsDependantResourceModel() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("") }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <ScenarioModel>())) .ReturnsAsync(httpResponseMessage); var scenarioClient = new ScenarioClient(httpService.Object); // Act var result = await scenarioClient.MarkScenario(ScenarioModelDataMocks.MockScenarioModel()); // Assert Assert.NotNull(result); }
public async void GetScenariosForProject_NoContentStatusCode_ReturnsEmptyList() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.NoContent, Content = new StringContent("") }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); var scenarioClient = new ScenarioClient(httpService.Object); // Act var result = await scenarioClient.GetScenariosForProject(It.IsAny <string>()); // Assert Assert.Empty(result); }
private void Awake() { Instance = this; }
public void Importa() { Calcola_Percorsi_Intermedi().ContinueWith(t => { var service = new ScenarioClient(); service.Create_ScenarioCompleted += (sender, e) => { //TODO }; var command = new Create_Scenario { Scenario = new ScenarioDto { Id = Id, Date = DateTime.Now, Name = "asd", UserId = RoutingViewModel.Instance.UserId, Orders = Points.Select(p => new OrderDto { ExternalId = p.ExternalReference, Delivering = p.Shipping, DestinationId = p.Destination.Id, DestinationExternalId = p.Destination.Id, Latitude = p.Destination.Location.Latitude, Longitude = p.Destination.Location.Longitude, Volume = p.Amount.Value, Volume_Unit = p.Amount.Unit, Description = "nessuna ", Address = p.Destination.Resolved_Address.FormattedAddress }) .To_ObservableCollection(), Distances = t.Result.Select(d => new DistanceDto { From_Latitide= d.From.Latitude, From_Longitude = d.From.Longitude, To_Latitide = d.To.Latitude, To_Longitude = d.To.Longitude, Km= d.Km, TimeInSeconds = d.TimeInSeconds }).To_ObservableCollection(), } }; service.Create_ScenarioAsync(command); }); }
public void Carica() { var service = new ScenarioClient(); service.Get_ScenarioCompleted += (sender, e) => { }; service.Get_ScenarioAsync("123"); }