public void WhenTenureExists_ReturnsTenureInformation() { // Arrange ApiGateway client = new ApiGateway(new HttpClientFactoryWrapper(Client)); var assetResponse = _fixture.Create <AssetResponseObject>(); MockApiGateway.SetAssetApiResponse(assetResponse); var tenureResponse = _fixture.Create <TenureResponseObject>(); MockApiGateway.SetTenureInformationApiResponse(tenureResponse); var propertyReference = _fixture.Create <string>(); // Act var response = client.ExecuteRequest <PropertyResponse>("dummy", new Uri($"/api/v2/properties/{propertyReference}", UriKind.Relative)).Result; // Assert response.IsSuccess.Should().BeTrue(); response.Status.Should().Be(HttpStatusCode.OK); response.Content.Tenure.TypeCode.Should().Be(tenureResponse.TenureType.Code); response.Content.Tenure.TypeDescription.Should().Be(tenureResponse.TenureType.Description); }
public void GetPropertyWithAlerts(int propertyAlertCount, int personAlertCount, bool canRaiseRepair) { // Arrange var legacyReferenceValue = new Faker().Random.String2(10) + "/01"; var assetResponse = GenerateAssetResponse(canRaiseRepair); var tenureResponse = GenerateTenure(canRaiseRepair, legacyReferenceValue); MockApiGateway.SetAssetApiResponse(assetResponse); MockApiGateway.SetTenureInformationApiResponse(tenureResponse); MockApiGateway.AddPropertyAlerts(propertyAlertCount, assetResponse.AssetId); MockApiGateway.AddPersonAlerts(personAlertCount, legacyReferenceValue); MockApiGateway.AddResidentContacts(); ApiGateway client = new ApiGateway(new HttpClientFactoryWrapper(Client)); // Act var response = client.ExecuteRequest <PropertyResponse>("dummy", new Uri($"/api/v2/properties/{assetResponse.AssetId}", UriKind.Relative)).Result; // Assert response.IsSuccess.Should().BeTrue(); response.Status.Should().Be(HttpStatusCode.OK); response.Content.Property.Should().BeEquivalentTo(assetResponse.ToDomain().ToResponse(tenureResponse.ToDomain())); response.Content.Alerts.LocationAlert.Should().HaveCount(propertyAlertCount); response.Content.Alerts.PersonAlert.Should().HaveCount(personAlertCount); response.Content.Property.CanRaiseRepair.Should().Be(canRaiseRepair); }
[Test] // For new Contact Details API public void WhenContactDetailsExist_ReturnsContactDetails() { // Arrange ApiGateway client = new ApiGateway(new HttpClientFactoryWrapper(Client)); var assetResponse = _fixture.Create <AssetResponseObject>(); MockApiGateway.SetAssetApiResponse(assetResponse); var tenureResponse = _fixture.Create <TenureResponseObject>(); MockApiGateway.SetTenureInformationApiResponse(tenureResponse); var propertyReference = _fixture.Create <string>(); var contactDetailsResponse = new ContactDetailsResponse { Results = _fixture.CreateMany <ContactDetailsResponseObject>(3) }; MockApiGateway.SetContactDetailsApiResponse(contactDetailsResponse); // Act var response = client.ExecuteRequest <PropertyResponse>("dummy", new Uri($"/api/v2/properties/{propertyReference}", UriKind.Relative)).Result; // Assert response.IsSuccess.Should().BeTrue(); response.Status.Should().Be(HttpStatusCode.OK); response.Content.ContactDetails.Should().NotBeNull(); response.Content.ContactDetails.Should().HaveCount(contactDetailsResponse.Results.Count()); }
public void GetAlerts(int expectedPropertyAlertCount, int expectedPersonAlertCount) { // Arrange var legacyReferenceValue = new Faker().Random.String2(10) + "/01"; var tenureResponse = GenerateTenure(legacyReferenceValue); var expectedProperty = _fixture.Create <AssetResponseObject>(); expectedProperty.Tenure.Id = tenureResponse.Id.ToString(); MockApiGateway.SetAssetApiResponse(expectedProperty); MockApiGateway.SetTenureInformationApiResponse(tenureResponse); MockApiGateway.AddPropertyAlerts(expectedPropertyAlertCount, expectedProperty.AssetId); MockApiGateway.AddTenantInformation(legacyReferenceValue, expectedProperty.AssetId); MockApiGateway.AddPersonAlerts(expectedPersonAlertCount, legacyReferenceValue); ApiGateway client = new ApiGateway(new HttpClientFactoryWrapper(Client)); // Act var response = client.ExecuteRequest <CautionaryAlertResponseList>("dummy", new Uri($"/api/v2/properties/{expectedProperty.AssetId}/alerts", UriKind.Relative)).Result; // Assert response.IsSuccess.Should().BeTrue(); response.Status.Should().Be(HttpStatusCode.OK); response.Content.PropertyReference.Should().Be(expectedProperty.AssetId); response.Content.LocationAlert.Should().HaveCount(expectedPropertyAlertCount); response.Content.PersonAlert.Should().HaveCount(expectedPersonAlertCount); }
public void WhenAssetExists_ReturnsAsset() { // Arrange ApiGateway client = new ApiGateway(new HttpClientFactoryWrapper(Client)); var assetResponse = _fixture.Create <AssetResponseObject>(); MockApiGateway.SetAssetApiResponse(assetResponse); MockApiGateway.SetTenureInformationApiResponse(null); var propertyReference = _fixture.Create <string>(); // Act var response = client.ExecuteRequest <PropertyResponse>("dummy", new Uri($"/api/v2/properties/{propertyReference}", UriKind.Relative)).Result; // Assert response.IsSuccess.Should().BeTrue(); response.Status.Should().Be(HttpStatusCode.OK); var tenure = _fixture.Create <RepairsApi.V2.Domain.TenureInformation>(); response.Content.Property.Should().BeEquivalentTo(assetResponse.ToDomain().ToResponse(tenure)); }