public void Get_WithPlantMatchingGuidInRepo_ShouldReturnMatchingPlant() { using (var context = new RamosiContext(options)) { // Arrange var plants = new List <Plant>() { new PlantBuilder() .WithGuid(guidOne) .WithPlantCharacteristic(new PlantCharacteristicBuilder().WithGuid(guidOne)), new PlantBuilder() .WithGuid(guidTwo) .WithPlantCharacteristic(new PlantCharacteristicBuilder().WithGuid(guidTwo)), new PlantBuilder() .WithGuid(guidThree) .WithPlantCharacteristic(new PlantCharacteristicBuilder().WithGuid(guidThree)), }; context.Plants.AddRange(plants); context.SaveChanges(); var repo = new PlantRepository(context); // Act var plant = repo.Get(guidTwo); // Assert Assert.AreEqual(guidTwo, plant.Guid); Assert.AreEqual(guidTwo, plant.PlantCharacteristic.Guid); } }
public void GetAll_WithNoPlantsInRepo_ShouldReturnEmptyCollection() { using (var context = new RamosiContext(options)) { // Arrange var repo = new PlantRepository(context); // Act var plants = repo.Get(); // Assert Assert.IsFalse(plants.Any()); } }
public void Get_WithNoPlantsInRepo_ShouldReturnNull() { using (var context = new RamosiContext(options)) { // Arrange var repo = new PlantRepository(context); // Act var plant = repo.Get(guidOne); // Assert Assert.IsNull(plant); } }
public void GetAll_WithPlantsInRepo_ShouldReturnAllPlants() { using (var context = new RamosiContext(options)) { // Arrange var plantsInRepo = new List <Plant>() { new PlantBuilder() .WithGuid(guidOne) .WithPlantCharacteristic(new PlantCharacteristicBuilder().WithGuid(guidOne)), new PlantBuilder() .WithGuid(guidTwo) .WithPlantCharacteristic(new PlantCharacteristicBuilder().WithGuid(guidTwo)), new PlantBuilder() .WithGuid(guidThree) .WithPlantCharacteristic(new PlantCharacteristicBuilder().WithGuid(guidThree)), }; context.Plants.AddRange(plantsInRepo); context.SaveChanges(); var repo = new PlantRepository(context); // Act var plants = repo.Get(); // Assert Assert.AreEqual(3, plants.Count()); var results = plants.ToList(); Assert.AreEqual(guidOne, results[0].Guid); Assert.AreEqual(guidOne, results[0].PlantCharacteristic.Guid); Assert.AreEqual(guidTwo, results[1].Guid); Assert.AreEqual(guidTwo, results[1].PlantCharacteristic.Guid); Assert.AreEqual(guidThree, results[2].Guid); Assert.AreEqual(guidThree, results[2].PlantCharacteristic.Guid); } }
public Plant Get(int id) { return(_plantRepository.Get(id)); }