public void FujiUserRepo_UserWhoHasntEatenAnyApplesReturnsCountOf_0() { // Arrange IFujiUserRepository fujiUserRepo = new FujiUserRepository(_mockContext.Object); // Act Apple[] apples = new Apple[] { new Apple { Id = 1, VarietyName = "MacBook", ScientificName = "Galus Indictus" }, new Apple { Id = 2, VarietyName = "iPhone", ScientificName = "Poculum Relego" }, new Apple { Id = 3, VarietyName = "iWatch", ScientificName = "Inflo Fugitivus" } }; Dictionary <Apple, int> result = fujiUserRepo.GetCountOfSpecificApplesEaten(apples, new FujiUser { Id = 1 }); // Assert Assert.That(result[apples[0]], Is.EqualTo(0)); Assert.That(result[apples[1]], Is.EqualTo(0)); Assert.That(result[apples[2]], Is.EqualTo(0)); }
public void FujiUserRepo_AskingForWhichApplesEatenWhenSupplyingOnlySpecificApplesCorrectlyFiltersList() { // Arrange // (not good to have logic in the arrange here, i.e. the _users.Where to select which user we're setting it up for // Could have hard-coded it in as element #2 of the list but that is fragile since we might edit that stub data // in the future and it could break the test for no good reason. IFujiUserRepository fujiUserRepo = new FujiUserRepository(_mockContext.Object); // Act Apple[] apples = new Apple[] { new Apple { Id = 1, VarietyName = "MacBook", ScientificName = "Galus Indictus" }, //new Apple {Id = 2, VarietyName = "iPhone", ScientificName = "Poculum Relego" }, new Apple { Id = 3, VarietyName = "iWatch", ScientificName = "Inflo Fugitivus" } }; Dictionary <Apple, int> result = fujiUserRepo.GetCountOfSpecificApplesEaten(apples, new FujiUser { Id = 2 }); // Assert Assert.That(result.Count == 2); Assert.That(result[apples[0]], Is.EqualTo(1)); Assert.That(result[apples[1]], Is.EqualTo(1)); }