public async void ShouldGetAllCorrectly() { var context = new FakeRecipesDbContext(); var result = await context.GetAll(); var expected = new Recipe { Id = new Guid("0104838E-ABDF-4FB4-9B20-12B97833AF5D"), Metadata = new Metadata { Version = 1, Removed = false, Creation = new Creation { AuthorId = "F8B5EF68-2526-4635-8C91-A5AB98465D0F", Published = new DateTime(2010, 1, 1) }, Updates = new Update[0] }, Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-picture.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; var enumerable = result as Recipe[] ?? result.ToArray(); enumerable.Should().HaveCount(1); enumerable.Should().ContainSingle(x => x.WithDeepEqual(expected).Compare()); }
public async void ShouldAddCorrectly() { var context = new FakeRecipesDbContext(); var recipe = new Recipe { Id = new Guid("0161C29D-45A7-412B-8232-BC598CBD7CA1"), Metadata = new Metadata { Version = 1, Removed = false, Creation = new Creation { AuthorId = "F8B5EF68-2526-4635-8C91-A5AB98465D0F", Published = new DateTime(2010, 1, 1) }, Updates = new Update[0] }, Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-picture.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; await context.Add(recipe); await context.SaveChanges(); context.Recipes .Should().HaveCount(2) .And.ContainSingle(x => x.Id == Guid.Parse("0104838E-ABDF-4FB4-9B20-12B97833AF5D")); }
public async void ShouldGetByIdCorrectly() { var context = new FakeRecipesDbContext(); var result = await context.GetById(new Guid("0104838E-ABDF-4FB4-9B20-12B97833AF5D")); var expected = new Recipe { Id = new Guid("0104838E-ABDF-4FB4-9B20-12B97833AF5D"), Metadata = new Metadata { Version = 1, Removed = false, Creation = new Creation { AuthorId = "F8B5EF68-2526-4635-8C91-A5AB98465D0F", Published = new DateTime(2010, 1, 1) }, Updates = new Update[0] }, Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-picture.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; result.Should().BeEquivalentTo(expected); }