public async Task GetAddresses_FakeUserId_ShouldReturnCountOfZero() { var sut = new GetAddressesQueryHandler(_fixture.Context); var result = await sut.Handle(new GetAddressesQuery() { UserId = Guid.NewGuid() }, CancellationToken.None); var resultCount = result.Addresses.Count(); result.ShouldBeOfType <AddressListViewModel>(); resultCount.ShouldBe(0); }
public async Task GetAddresses_ExistingUserId_ShouldReturnAddresses() { var sut = new GetAddressesQueryHandler(_fixture.Context); var result = await sut.Handle(new GetAddressesQuery() { UserId = _fixture.CurrentUser.Id }, CancellationToken.None); var resultCount = result.Addresses.Count(); result.ShouldBeOfType <AddressListViewModel>(); resultCount.ShouldBe(2); }
public async Task Then_Gets_Addresses_From_Locations_Api( GetAddressesQuery query, GetAddressesListResponse apiResponse, [Frozen] Mock <ILocationApiClient <LocationApiConfiguration> > mockApiClient, GetAddressesQueryHandler handler) { mockApiClient .Setup(client => client.Get <GetAddressesListResponse>(It.IsAny <GetAddressesQueryRequest>())) .ReturnsAsync(apiResponse); var result = await handler.Handle(query, CancellationToken.None); result.AddressesResponse.Addresses.Should().BeEquivalentTo(apiResponse.Addresses); }
public async Task Then_The_Service_Is_Called( string searchTerm, GetAddressesQuery query, List <SuggestedAddress> addresses, [Frozen] Mock <IAddressesService> service, GetAddressesQueryHandler handler) { //Arrange query.Query = searchTerm; service.Setup(x => x.FindFromDpaDataset(query.Query, query.MinMatch)).ReturnsAsync(addresses); //Act var actual = await handler.Handle(query, CancellationToken.None); //Assert actual.Addresses.Should().BeEquivalentTo(addresses); }