Exemple #1
0
        public void Create()
        {
            int oldCount = Entities.Count();
            int newId    = oldCount + 1;
            var entity   = CreateTestEntity(newId);

            var result = _controller.Create(entity);

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode,
                            "Create action with valid model should result in Created");

            Assert.AreEqual(oldCount + 1, Entities.Count(), "Create action should add new entity");
            var savedEntity = Entities.SingleOrDefault(d => d.Id == newId);

            Assert.IsNotNull(savedEntity, "Entity does not seem to be added");
            Assert.IsTrue(entity.ToEntity().Equals(savedEntity), "Original and saved entities differ");
        }