public async void TestPut()
        {
            using (var client = server.CreateClient().AcceptJson())
            {
                var service = new StrategicImportanceService();
                var item    = service.GetAll().FirstOrDefault();

                if (item == null)
                {
                    this.TestPost();
                    item = service.GetAll().FirstOrDefault();
                }

                var    itemId = item.Id;
                string unique = (Guid.NewGuid()).ToString();

                item.Name = unique;

                var response = await client.PutAsJsonAsync(string.Format("/api/StrategicImportances/{0}", itemId), item);

                var result = await response.Content.ReadAsJsonAsync <StrategicImportance>();

                item = service.GetById(itemId);

                Assert.True(item.Name.Equals(unique, StringComparison.OrdinalIgnoreCase));
                Assert.Equal((int)response.StatusCode, 200);
            }
        }
        public async void TestPost()
        {
            using (var client = server.CreateClient().AcceptJson())
            {
                var step        = 1;
                var service     = new StrategicImportanceService();
                var countBefore = service.GetAll().Count();
                var item        = service.GetAll().FirstOrDefault();
                if (item == null)
                {
                    var newItem = new StrategicImportance()
                    {
                        Id   = 0,
                        Name = string.Format("StrategicImportance {0}", countBefore)
                    };

                    service.Add(item);
                    item = service.GetAll().FirstOrDefault();

                    step = 2;
                }

                var response = await client.PostAsJsonAsync("/api/StrategicImportances", item);

                var result = await response.Content.ReadAsJsonAsync <StrategicImportance>();

                var countAfter = service.GetAll().Count();

                Assert.Equal(countBefore, countAfter - step);
                Assert.Equal((int)response.StatusCode, 201);
            }
        }
        public void TestDelete()
        {
            this.TestAdd();

            ConfigurationHelper.Ensure();
            var service = new StrategicImportanceService();

            var countBefore = service.GetAll().Count();

            var maxId = service.GetAll().Max(i => i.Id);

            service.Delete(maxId);

            var countAfter = service.GetAll().Count();

            Assert.Equal(countBefore, countAfter + 1);
        }
        public async void TestDelete()
        {
            using (var client = server.CreateClient().AcceptJson())
            {
                var service     = new StrategicImportanceService();
                var maxId       = service.GetAll().Max(i => i.Id);
                var countBefore = service.GetAll().Count();

                var response = await client.DeleteAsync(string.Format("/api/StrategicImportances/{0}", maxId));

                var result = await response.Content.ReadAsJsonAsync <StrategicImportance>();

                var countAfter = service.GetAll().Count();

                Assert.Equal(countBefore, countAfter + 1);
                Assert.Equal((int)response.StatusCode, 200);
            }
        }
        public void TestAdd()
        {
            ConfigurationHelper.Ensure();

            var service = new StrategicImportanceService();

            var countBefore = service.GetAll().Count();

            var newItem = new StrategicImportance()
            {
                Id   = 0,
                Name = string.Format("StrategicImportance {0}", countBefore)
            };

            service.Add(newItem);

            var countAfter = service.GetAll().Count();

            Assert.Equal(countBefore, countAfter - 1);
        }
        public void TestUpdate()
        {
            ConfigurationHelper.Ensure();

            var service = new StrategicImportanceService();

            var item = service.GetAll().FirstOrDefault();

            if (item == null)
            {
                this.TestAdd();
                item = service.GetAll().FirstOrDefault();
            }

            var    itemId = item.Id;
            string unique = (Guid.NewGuid()).ToString();

            item.Name = unique;
            service.Update(item);

            item = service.GetById(itemId);
            Assert.True(item.Name.Equals(unique, StringComparison.OrdinalIgnoreCase));
        }
        public async void TestGetAll()
        {
            using (var client = server.CreateClient().AcceptJson())
            {
                var response = await client.GetAsync("/api/StrategicImportances");

                var result = await response.Content.ReadAsJsonAsync <List <StrategicImportance> >();

                var service = new StrategicImportanceService();
                var count   = service.GetAll().Count();

                Assert.Equal(result.Count, count);
            }
        }