public async Task Update_ValidParameters_SetsCorrectResourceAndMethod() { var sut = new LabelRepository(_requestFactory); await sut.Update(0, "name"); _requestFactory.Received().Create("projects/{projectId}/labels", Method.Put); }
public async Task Update_ValidParameters_AddsProjectIdUrlSegment() { const uint expected = 0; var sut = new LabelRepository(_requestFactory); await sut.Update(expected, "name"); _request.Received().AddUrlSegment("projectId", expected); }
public async Task Update_ValidParameters_AddsNameParameter() { const string expected = "name"; var sut = new LabelRepository(_requestFactory); await sut.Update(0, expected); _request.Received().AddParameter("name", expected); }
public async Task Update_NewNameIsSet_AddsNewNameParameter() { const string expected = "newName"; var sut = new LabelRepository(_requestFactory); await sut.Update(0, "name", expected); _request.Received().AddParameterIfNotNull("new_name", expected); }
public async Task Update_DescriptionIsSet_AddsDescriptionParameter() { const string expected = "description"; var sut = new LabelRepository(_requestFactory); await sut.Update(0, "name", description : expected); _request.Received().AddParameterIfNotNull("description", expected); }
public async Task Update_ColorIsSet_AddsColorParameter() { const string expected = "color"; var sut = new LabelRepository(_requestFactory); await sut.Update(0, "name", color : expected); _request.Received().AddParameterIfNotNull("color", expected); }
public int Update(Label model) { var dbModel = _labelRepository.SelectByName(model.Name); if (dbModel != null && dbModel.LabelId != model.LabelId) { throw new ValidateException(301, "标签已存在"); } model.UpdateTime = DateTime.Now; return(_labelRepository.Update(model)); }
public ActionResult Detail(int?id, Labels model) { LabelRepository objlab = new LabelRepository(SessionCustom); objlab.Entity = model.LabelCustom; SetLabel(); if (id != null) { objlab.Entity.LabelId = id; objlab.Update(); this.InsertAudit("Update", this.Module.Name + " -> " + objlab.Entity.Name); } else { objlab.Entity.LanguageId = CurrentLanguage.LanguageId; objlab.Insert(); this.InsertAudit("Insert", this.Module.Name + " -> " + objlab.Entity.Name); } return(this.RedirectToAction("Index", "Label")); }
public async Task Update_NameIsNull_ThrowsArgumentNullException() { var sut = new LabelRepository(_requestFactory); await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Update(0, null)); }