コード例 #1
0
        public void  GetById_CuandoSeUtilizaConUnIDValido_TraeElDetalleDelRegistro()
        {
            context.Database.EnsureDeleted();
            Post fakePost = new Post
            {
                Title = "Post C",
                Body  = "Cuerpo del post 3",
                Autor = "Luis"
            };
            var newPost = context.Posts.Add(fakePost).Entity;
            var SUT     = new InMemoryPostDb(context);

            var result = SUT.GetById(newPost.Id);

            context.Posts.Find(newPost.Id).Should().BeEquivalentTo(result);
        }
コード例 #2
0
        public void Update_TestOFTheInMemoryPostDB()
        {
            context.Database.EnsureDeleted();
            Post fakePost = new Post
            {
                Title = "Post D",
                Body  = "Cuerpo del post 4",
                Autor = "Luis"
            };

            var SUT = new InMemoryPostDb(context);
            //var newPost = context.Posts.Add(fakePost).Entity;
            var newPost = SUT.Add(fakePost);

            fakePost.Body = "Actualizado";
            SUT.Update(fakePost);

            var UpdatedPost = SUT.GetById(newPost.Id);

            //context.Posts.Find(newPost.Body).Should().BeEquivalentTo(UpdatedPost.Body);
            UpdatedPost.Body.Should().Be(fakePost.Body);
        }