public async Task HandleGet_Exception_TestAsync() { var id = ObjectId.GenerateNewId(); var request = new GetWoodyPlantRequest(id); var expectedPlant = new WoodyPlantDocument { Id = id }; fWoodyPlantsRepository .GetByIdAsync(Arg.Is(id), Arg.Is(default(CancellationToken))) .Returns((WoodyPlantDocument?)null); await Assert.ThrowsAsync <NotFoundException>(async() => await new WoodyPlantsRequestHandler(fWoodyPlantsRepository, fVersionRepository).Handle(request, default)); }
public async Task HandleGet_Success_TestAsync() { var id = ObjectId.GenerateNewId(); var request = new GetWoodyPlantRequest(id); var expectedPlant = new WoodyPlantDocument { Id = id, TextMatchScore = 5, ImageUrls = new[] { "http://obj.cz" }, Location = new LocationDocument { Name = "Loc", Geometry = new PointGeometry() }, InnerWoodyPlantIds = Array.Empty <ObjectId>(), LocalizedNames = new LocalizedStringDocument { Czech = "name" }, LocalizedNotes = new LocalizedStringDocument { Czech = "note" }, LocalizedSpecies = new LocalizedStringDocument { Czech = "specie" }, Type = PlantType.AreaOfTrees, Version = null, }; fWoodyPlantsRepository .GetByIdAsync(Arg.Is(id), Arg.Is(default(CancellationToken))) .Returns(expectedPlant); var result = await new WoodyPlantsRequestHandler(fWoodyPlantsRepository, fVersionRepository).Handle(request, default); Assert.NotNull(result); Assert.Equal(expectedPlant.Id, result.Id); Assert.Equal(expectedPlant.LocalizedSpecies.Czech, result.LocalizedSpecies.Czech); Assert.Equal(expectedPlant.LocalizedNames.Czech, result.LocalizedNames.Czech); Assert.Equal(expectedPlant.LocalizedNotes.Czech, result.LocalizedNotes.Czech); Assert.Equal(expectedPlant.Location.Name, result.Location !.Name); Assert.Equal(expectedPlant.Location.Geometry.Type, result.Location.Geometry !.Type); var image = Assert.Single(result.ImageUrls); Assert.Equal("http://obj.cz", image); }