Example #1
0
        public async Task POST_Is_OK()
        {
            var controller = new RegionsController(Context);

            ConfigureRequest(controller);

            var model = new RegionModel
            {
                Name = "Test No Id"
            };

            var result = await GetResponse(controller.Post(model));

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Example #2
0
        public async Task POST_Inserts_Records()
        {
            var controller = new RegionsController(Context);

            ConfigureRequest(controller);

            var initialCount = Context.Regions.Count();

            var model = new RegionModel
            {
                Name = "Test No Id"
            };

            var result = await GetData <RegionModel>(controller.Post(model));

            Assert.IsNotNull(result);
            Assert.AreEqual(model.Name, result.Name);
            Assert.AreNotEqual(Guid.Empty, result.Id);
        }
Example #3
0
        public async Task POST_Fails_Duplicate_Records()
        {
            var controller = new RegionsController(Context);

            ConfigureRequest(controller);

            var model = new RegionModel
            {
                Name = "Test No Id"
            };

            Context.Regions.Add(new Region
            {
                Name = model.Name
            });
            Context.SaveChanges();

            var result = await GetResponse(controller.Post(model));

            Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
        }