public void Insert()
        {
            //Setup
            Gender gender = new Gender
            {
                Description = "SLTEST"
            };
            GenderList genders = new GenderList();

            genders.Load();
            int originalCount = genders.Count();



            //Act
            HttpClient client = InitializeClient();
            //Serialize a gender object that we're trying to insert
            string serializedGender = JsonConvert.SerializeObject(gender);
            var    content          = new StringContent(serializedGender);

            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync("Gender", content).Result;

            //Assert
            genders.Clear();
            genders.Load();
            Assert.AreEqual(originalCount + 1, genders.Count);
        }
Esempio n. 2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public MyDetialViewModel()
        {
            snackbar = new SnackbarMessageQueue();
            GenderList.Clear();
            GenderList.Add("女");
            GenderList.Add("男");
            InitialCommands();

            #region Register Messenger
            Messenger.Default.Register <bool>(this, UserDetailNotifications.ShowMyDetial, (value) =>
            {
                LoadDetials();
            });
            #endregion
        }
        public void Delete()
        {
            //Setup
            GenderList genders = new GenderList();

            genders.Load();
            int    originalCount = genders.Count();
            Gender gender        = genders.FirstOrDefault(g => g.Description == "SLTEST1");


            //Act
            if (gender != null)
            {
                HttpClient          client   = InitializeClient();
                HttpResponseMessage response = client.DeleteAsync("Gender/" + gender.Id).Result;
            }

            //Assert
            genders.Clear();
            genders.Load();
            Assert.AreEqual(originalCount - 1, genders.Count);
        }