public void Test_AddPlantWithMixedRequirementsANDMultipleFailingRequirements_ShouldReturnListWithFailing() { Plant successPlant = new Plant("success plant"); Plant failPlant = new Plant("fail plant"); successPlant.AddRequirement(new MockRequirement(true)); failPlant.AddRequirement(new MockRequirement(false)); failPlant.AddRequirement(new MockRequirement(false)); _plantGroup.AddPlant(successPlant); _plantGroup.AddPlant(failPlant); var incompatibleItems = _plantGroup.GetAllIncompatibilities(new Plant("plant 3")); Assert.Single(incompatibleItems); Assert.Equal(incompatibleItems.First().Item1.Name, failPlant.Name); Assert.False(incompatibleItems.First().Item2.Cast <MockRequirement>().First().ShouldFulfillRequirement); Assert.Equal(2, incompatibleItems.First().Item2.Count); }
public void Test_AddPlantsWithFailingRequirements_ShouldReturnListWithPlan() { Plant plant1 = new Plant("plant 1"); plant1.AddRequirement(new MockRequirement(false)); _plantGroup.AddPlant(plant1); List <(Plant, List <IPlantRequirement>)> incompatiblePlants = _plantGroup.GetAllIncompatibilities(new Plant("plant 2")); Assert.Equal(incompatiblePlants.First().Item1.Name, plant1.Name); Assert.Single(incompatiblePlants); }
public void Test_PlantWithPassingRequirement_ShouldReturnEmptyList() { Plant plant1 = new Plant("plant 1"); Plant plant2 = new Plant("plant 2"); plant1.AddRequirement(new MockRequirement(true)); _plantGroup.AddPlant(plant1); List <(Plant, List <IPlantRequirement>)> incompatiblePlants = _plantGroup.GetAllIncompatibilities(plant2); Assert.Empty(incompatiblePlants); }
public void Test_AddPlantWithMultipleFailingRequirements_ShouldReturnListWithFailing() { Plant failPlant1 = new Plant("fail plant 1"); Plant failPlant2 = new Plant("fail plant 2"); failPlant1.AddRequirement(new MockRequirement(true)); failPlant2.AddRequirement(new MockRequirement(true)); failPlant1.AddRequirement(new MockRequirement(false)); failPlant2.AddRequirement(new MockRequirement(false)); _plantGroup.AddPlant(failPlant1); _plantGroup.AddPlant(failPlant2); var incompatibleItems = _plantGroup.GetAllIncompatibilities(new Plant("plant 3")); Assert.Equal(2, incompatibleItems.Count); Assert.Equal(incompatibleItems.First().Item1.Name, failPlant1.Name); Assert.Equal(incompatibleItems[1].Item1.Name, failPlant2.Name); Assert.False(incompatibleItems.First().Item2.Cast <MockRequirement>().First().ShouldFulfillRequirement); Assert.False(incompatibleItems[1].Item2.Cast <MockRequirement>().First().ShouldFulfillRequirement); }
public void Test_SinglePassingRequirement_ShouldReturnEmptyList() { _plant1.AddRequirement(new MockRequirement(true)); List <IPlantRequirement> failed_requirements = _plant1.ReasonsForIncompatibility(_plant2); Assert.Empty(failed_requirements); }
public Plant GetByName(string name) { var plantDB = new db.plants.Plants(); var plantID = plantDB.Convert(name); db.plants.PlantInfo plantInfo = plantDB.PlantData(plantID); List <IPlantRequirement> requirements = new List <IPlantRequirement>(); requirements.Add(new SunlightCompatibilityRequirement(plantInfo.Sunlight)); requirements.Add(new TemperatureCompatibilityRequirement(plantInfo.Temperature)); requirements.Add(new WaterCompatibilityRequirement(plantInfo.Rainfall)); //soil req var plantType = plantInfo.Type; var description = plantDB.Description(plantID); Plant plant = new Plant(name); //TODO(zlef): DELETE================================================================================== plant.tempString.Add("Sunlight: " + plantInfo.Sunlight.ToString()); plant.tempString.Add("temperature: " + plantInfo.Temperature.ToString()); plant.tempString.Add("Rainfall: " + plantInfo.Rainfall.ToString()); //==================================================================================================== plant.plantType = plantType; foreach (IPlantRequirement requirement in requirements) { plant.AddRequirement(requirement); } plant.AddDescription(description); return(plant); }
public void Test_NewRequirement_AddRequirementMethod() { _plant.AddRequirement(new MockPlantRequirement()); }