コード例 #1
0
        public void IsCreatable()
        {
            Random        random    = new Random(DateTime.Now.Millisecond);
            Administrator testAdmin = new Administrator
            {
                DormitoryId  = 2,
                Name         = Generation.GetRandomAlphaNumeric(),
                Password     = Generation.GetRandomAlphaNumeric(),
                PersonalCode = random.Next(),
                Surname      = Generation.GetRandomAlphaNumeric(),
                Username     = Generation.GetRandomAlphaNumeric()
            };
            HttpResponseMessage response = repository.Create(testAdmin);
            string        jsonContents   = response.Content.ReadAsStringAsync().Result;
            Administrator createdAdmin   = JsonConvert.DeserializeObject <Administrator>(jsonContents);

            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.Created, "Admnistrator creation test has failed.");
            Assert.Equals(testAdmin, createdAdmin);
        }