Ejemplo n.º 1
0
        public async Task ById()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "B_Database")
                          .Options;
            var dbContext   = new ApplicationDbContext(options);
            var postService = new PostService(dbContext);

            await postService.CreatePostAsync("Tweets", "Hello i am tweet", "u1", 1);

            var post = await postService.ByIdAsync(1);

            Assert.Equal(1, post.Id);
            Assert.Equal("Tweets", post.Title);
            Assert.Equal("Hello i am tweet", post.Content);
            Assert.Equal("u1", post.UserId);
        }