public void TestCanViewPlantInfos() { var plantInfos = FakePlantInfos.Get().AsQueryable(); var visiblePlantInfos = plantInfos.CanViewContent(FakeUsers.GetPublic().AsModel()); visiblePlantInfos.Should().HaveCount(2); }
public async Task TestAddOrUpdatePlantInfoAsync() { var plantInfoService = new PlantInfoService(_mockPlantInfoRepository.Object, _mockPlantLocationRepository.Object, _mockPlantInfoIndex.Object); var plantInfo = FakePlantInfos.Get().First().AsModel(); var plantInfoResult = await plantInfoService.AddOrUpdatePlantInfoAsync(plantInfo); plantInfoResult.Should().NotBeNull("it exists"); }
public void TestAsSearchModel() { var plantInfos = FakePlantInfos.Get(); var synonyms = FakeSynonyms.Get(); var plantInfoModels = plantInfos.Select(p => p.AsSearchModel(null, synonyms)); var firstPlantInfo = plantInfoModels.First(); firstPlantInfo.CommonName.Should().Be("Dense Blazing Star"); firstPlantInfo.ScientificName.Should().Be("Liatris spicata"); firstPlantInfo.MinimumBloomTime.Should().Be((short)Month.Jul); firstPlantInfo.MaximumBloomTime.Should().Be((short)Month.Aug); firstPlantInfo.MinimumHeight.Should().Be(1); firstPlantInfo.MaximumHeight.Should().Be(2); firstPlantInfo.HeightUnit.Should().Be(DistanceUnit.Feet); firstPlantInfo.MinimumSpread.Should().Be(0.75); firstPlantInfo.MaximumSpread.Should().Be(1.5); firstPlantInfo.SpreadUnit.Should().Be(DistanceUnit.Feet); firstPlantInfo.MinimumWater.Should().Be(WaterType.Medium); firstPlantInfo.MaximumWater.Should().Be(WaterType.Medium); firstPlantInfo.MinimumLight.Should().Be(LightType.FullShade); firstPlantInfo.MaximumLight.Should().Be(LightType.FullSun); firstPlantInfo.MinimumZone.Id.Should().Be(7); firstPlantInfo.MaximumZone.Id.Should().Be(22); firstPlantInfo.Zones.Any(z => z.Id == 10).Should().BeTrue(); firstPlantInfo.StratificationStages.Should().HaveCount(1); firstPlantInfo.StratificationStages.Count(s => s.Step == 1).Should().Be(1); firstPlantInfo.StratificationStages.Count(s => s.DayLength == 30).Should().Be(1); firstPlantInfo.StratificationStages.Count(s => s.StratificationType == StratificationType.ColdMoist).Should().Be(1); firstPlantInfo.WildlifeEffects.Should().HaveCount(1); firstPlantInfo.WildlifeEffects.Count(we => we.Wildlife == Wildlife.Bees).Should().Be(1); firstPlantInfo.WildlifeEffects.Count(we => we.Effect == Effect.Food).Should().Be(1); firstPlantInfo.SoilTypes.Should().HaveCount(3); firstPlantInfo.SoilTypes.Count(s => s == SoilType.Loamy).Should().Be(1); firstPlantInfo.Notes.Contains("feather").Should().BeTrue(); firstPlantInfo.Visibility.Should().Be(Visibility.Contacts); firstPlantInfo.CreatedBy.Should().Be(Helpers.UserId); firstPlantInfo.ModifiedBy.Should().Be(Helpers.UserId); firstPlantInfo.DateCreated.Should().BeAfter(new DateTime()); firstPlantInfo.DateModified.Should().NotBeNull(); firstPlantInfo.User.DisplayName.Should().Be("Belvedere"); firstPlantInfo.PlantLocations.Should().HaveCount(1); firstPlantInfo.Lifeform.ScientificName.Should().Be("Liatris spicata"); firstPlantInfo.Synonyms.Should().HaveCount(1); }
public void TestSearchModelFromModel() { var plantInfos = FakePlantInfos.Get().Select(p => p.AsModel()); var plantInfoSearch = plantInfos.Select(p => p.AsSearchModel(null, null)).First(); plantInfoSearch.BloomTimes.Any(b => b == Month.Jul).Should().BeTrue(); plantInfoSearch.BloomTimes.Any(b => b == Month.Aug).Should().BeTrue(); plantInfoSearch.Zones.Any(z => z.Id == 7).Should().BeTrue(); plantInfoSearch.Zones.Any(z => z.Id == 12).Should().BeTrue(); plantInfoSearch.Zones.Any(z => z.Id == 22).Should().BeTrue(); plantInfoSearch.Zones.Should().HaveCount(16); plantInfoSearch.WaterTypes.Any(w => w == WaterType.Medium).Should().BeTrue(); plantInfoSearch.LightTypes.Any(l => l == LightType.FullShade).Should().BeTrue(); plantInfoSearch.LightTypes.Any(l => l == LightType.PartShade).Should().BeTrue(); plantInfoSearch.LightTypes.Any(l => l == LightType.PartSun).Should().BeTrue(); plantInfoSearch.LightTypes.Any(l => l == LightType.FullSun).Should().BeTrue(); plantInfoSearch.SoilTypes.Should().HaveCount(3); plantInfoSearch.SoilTypes.Count(s => s == SoilType.Loamy).Should().Be(1); plantInfoSearch = plantInfos.Select(p => p.AsSearchModel(p.Locations, null)).Skip(1).First(); plantInfoSearch.BloomTimes.Any(b => b == Month.Apr).Should().BeTrue(); plantInfoSearch.BloomTimes.Any(b => b == Month.May).Should().BeTrue(); plantInfoSearch.Zones.Any(z => z.Id == 13).Should().BeTrue(); plantInfoSearch.Zones.Any(z => z.Id == 17).Should().BeTrue(); plantInfoSearch.Zones.Any(z => z.Id == 22).Should().BeTrue(); plantInfoSearch.Zones.Should().HaveCount(10); plantInfoSearch.WaterTypes.Any(w => w == WaterType.Dry).Should().BeTrue(); plantInfoSearch.WaterTypes.Any(w => w == WaterType.MediumDry).Should().BeTrue(); plantInfoSearch.WaterTypes.Any(w => w == WaterType.Medium).Should().BeTrue(); plantInfoSearch.LightTypes.Any(l => l == LightType.PartShade).Should().BeTrue(); plantInfoSearch.LightTypes.Any(l => l == LightType.PartSun).Should().BeTrue(); plantInfoSearch.LightTypes.Any(l => l == LightType.FullSun).Should().BeTrue(); plantInfoSearch.WildlifeEffects.Count(we => we.Wildlife == Wildlife.Bees).Should().Be(1); plantInfoSearch.WildlifeEffects.Count(we => we.Effect == Effect.Food).Should().Be(1); plantInfoSearch.SoilTypes.Should().BeNull(); plantInfoSearch.Notes.Contains("feather"); }