private void Seed() { Badge b1 = new Badge(123, "Cool Guy Badge."); b1.doorNames.Add("A1"); Badge b2 = new Badge(1234, "Just a Guy Badge"); b2.doorNames.AddRange(new List <string>() { "A1", "B2", "C4" }); Badge b3 = new Badge(12345, "Probably still a cool guy but haven't gotten to know him yet badge."); br.Add(b1); br.Add(b2); br.Add(b3); }
public void Test_GetBadgeByID() { BadgeRepository br = new BadgeRepository(); Badge b1 = new Badge(123, "Cool Guy Badge."); b1.doorNames.Add("A1"); br.Add(b1.badgeID, b1); Assert.IsTrue(br._badges.ContainsKey(123)); }
public void Arrange() { Console.WriteLine("inside arrange"); _aBadge = new Badge(1, new List <string>() { "A4", "B1", "C7" }); _badgeRepo.Add(_aBadge); _aBadge = new Badge(2, new List <string>() { "A1", "A2", "A3", "A4" }); _badgeRepo.Add(_aBadge); _aBadge = new Badge(3, new List <string>() { "C5", "B2", "B1", "A1" }); _badgeRepo.Add(_aBadge); }//end of method Arrange
public void Test_IsDoorValidTrue() { BadgeRepository br = new BadgeRepository(); Badge b1 = new Badge(123, "Cool Guy Badge."); b1.doorNames.Add("A1"); br.Add(b1.badgeID, b1); Assert.IsTrue(br.IsVaildBadgeID(123)); Assert.IsFalse(br.IsVaildBadgeID(456)); }
public void Test_EditAddDoor() { BadgeRepository br = new BadgeRepository(); Badge b1 = new Badge(123, "Cool Guy Badge."); b1.doorNames.Add("A1"); br.Add(b1.badgeID, b1); br.Edit(123, "B1", "add"); Assert.IsTrue(b1.doorNames.Count == 2); }
public void Test_DeleteAllDoors() { BadgeRepository br = new BadgeRepository(); Badge b1 = new Badge(123, "Cool Guy Badge."); b1.doorNames.Add("A1"); br.Add(b1.badgeID, b1); br.DeleteAllDoors(123); Assert.IsTrue(b1.doorNames.Count == 0); }
public void CreateBadgeShouldReturnId() { var badge = new Badge { Title = "title", Description = "description", ImageUrl = "image" }; var addedBadge = badge; addedBadge.Id = 1; _context.Setup(x => x.Badges.Add(badge)).Returns(addedBadge); _repo.Add(badge); Assert.AreEqual(1, badge.Id); }
public HttpResponseMessage Post() { var formCollection = HttpContext.Current.Request.Form; HttpResponseMessage response; if (formCollection["Title"] == null || !HttpContext.Current.Request.Files.AllKeys.Any() || HttpContext.Current.Request.Files["Image"] == null) { response = Request.CreateResponse(HttpStatusCode.BadRequest); } else { var httpPostedFile = HttpContext.Current.Request.Files["Image"]; var fileName = Path.GetFileName(httpPostedFile.FileName); var award = new Badge { Title = formCollection["Title"], Description = formCollection["Description"], ImageUrl = fileName }; _badgeRepository.Add(award); if (award.Id == 0) { response = Request.CreateResponse(HttpStatusCode.ExpectationFailed, "error saving badge to db"); } else { var path = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["BadgeImageUploadPath"] + award.Id); var imagePath = $"{path}/{fileName}"; Directory.CreateDirectory(path); httpPostedFile.SaveAs(imagePath); response = Request.CreateResponse(HttpStatusCode.Created, award); var uri = Url.Link("DefaultApi", new { Id = award.Id }); response.Headers.Location = new Uri(uri); } } return(response); }