Ejemplo n.º 1
0
        public void GetExistingPost()
        {
            A.CallTo(() => this.service.GetById(1)).Returns(new Post { Id = 1 });

            var contoller = new PostsController(
                this.service, () => this.createCommand, () => this.updateCommand, this.connection);

            Post result = contoller.Get(1);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
Ejemplo n.º 2
0
        public void GetAllPosts()
        {
            A.CallTo(() => this.service.Get()).Returns(new List<Post> { new Post { Id = 1 } });

            var contoller = new PostsController(
                this.service, () => this.createCommand, () => this.updateCommand, this.connection);

            IList<Post> result = contoller.Get();

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result.First().Id, Is.EqualTo(1));
        }
Ejemplo n.º 3
0
        public void GetNonExistingPost()
        {
            A.CallTo(() => this.service.GetById(1)).Returns(null);

            var contoller = new PostsController(
                this.service, () => this.createCommand, () => this.updateCommand, this.connection);

            Assert.Throws<HttpResponseException>(() => contoller.Get(1));
        }