public async Task HandleAsync_SucessoAreaCalculada() { var mockTerrenoRepo = TerrenoRepositoryMock.GetMock(); var mockCoordenadaRepo = CoordenadaRepositoryMock.GetMock(); var terreno = new TerrenoRequestFake().GetTerrenoCom3Coordenadas(); mockTerrenoRepo.Setup(o => o.GetAsync(It.IsAny <long>(), It.IsAny <CancellationToken>())) .ReturnsAsync(terreno); var strategy = new RetornaTerrenoStrategy(AutomapperMock.GetProfilesMapper(), mockTerrenoRepo.Object, mockCoordenadaRepo.Object); mockCoordenadaRepo.Setup(o => o.Find(It.IsAny <Expression <Func <Coordenada, bool> > >(), It.IsAny <bool>())) .Returns(terreno.Coordenadas.AsQueryable()); var request = new TerrenoRequestFake().GetRetornaTerrenoQuery_Valido(); var response = await strategy.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.Equal(3, response.Coordenadas.Count()); Assert.True(response.SomaDistanciaPontos.valor > 0); Assert.True(response.AreaTotal.valor > 0); }
public async Task HandleAsync_Sucesso() { var mockUnitOfWork = DemarcacaoUnitOfWorkMock.GetMock(); var mockTerrenoRepo = TerrenoRepositoryMock.GetMock(); mockUnitOfWork.Setup(o => o.SaveChangesAsync(It.IsAny <CancellationToken>())) .ReturnsAsync(1); mockTerrenoRepo.Setup(o => o.AddAsync(It.IsAny <Terreno>(), It.IsAny <CancellationToken>())); var strategy = new CadastraTerrenoStrategy(AutomapperMock.GetProfilesMapper(), mockTerrenoRepo.Object, mockUnitOfWork.Object); var request = new TerrenoRequestFake().GetTerrenoRequest_Valido(); var response = await strategy.HandleAsync(request, CancellationToken.None); Assert.IsType <CadastraTerrenoResponse>(response); Assert.NotNull(response); }