예제 #1
0
        public void Delete_Created()
        {
            var fixture = PersonFixtures.Entity();

            service.Setup(x => x.Delete(fixture.Id)).Returns(true);

            var response = controller.Delete(fixture.Id);

            var responseResult = (StatusCodeResult)response;

            Assert.AreEqual(HttpStatusCode.Accepted, responseResult.StatusCode);
        }
예제 #2
0
        public void Read_Ok()
        {
            var fixture = PersonFixtures.Entity();

            service.Setup(x => x.Read(fixture.Id)).Returns(fixture);

            var response = controller.Read(fixture.Id);

            var responseResult = (OkNegotiatedContentResult <PersonEntity>)response;

            Assert.AreEqual(fixture.Id, responseResult.Content.Id);
            Assert.AreEqual(fixture.Name, responseResult.Content.Name);
            Assert.AreEqual(fixture.DOB, responseResult.Content.DOB);
        }
예제 #3
0
        public void Create_Created()
        {
            var input   = PersonFixtures.Input();
            var fixture = PersonFixtures.Entity(input);

            service.Setup(x => x.Create(input)).Returns(fixture);
            validator.Setup(x => x.Validate(input)).Returns(new ModelStateDictionary());

            var response = controller.Create(input);

            var responseResult = (CreatedNegotiatedContentResult <PersonEntity>)response;

            Assert.AreEqual(new Uri(string.Format("people/{0}", fixture.Id), UriKind.Relative), responseResult.Location);
            Assert.AreEqual(fixture.Id, responseResult.Content.Id);
            Assert.AreEqual(fixture.Name, responseResult.Content.Name);
            Assert.AreEqual(fixture.DOB, responseResult.Content.DOB);
        }