示例#1
0
        public async Task <IActionResult> Edit(SectionTypeViewModel pViewModelToUpdate)
        {
            if (!ModelState.IsValid)
            {
                return(View(pViewModelToUpdate));
            }

            // map to Dto
            SectionTypeDto lSectionTypeDto = Mapping.Mapper.Map <SectionTypeDto>(pViewModelToUpdate);

            await this._referenceServices.UpdateSectionType(lSectionTypeDto);

            return(RedirectToAction("Index", new { successMessage = "SectionType successfully updated" }));
        }
        public async Task TestEdit()
        {
            this.ReferenceServices.UpdateSectionType(Arg.Any <SectionTypeDto>()).Returns(Task.CompletedTask);

            SectionTypeViewModel lSectionTypeViewModel = new SectionTypeViewModel()
            {
                Name = "England"
            };
            IActionResult lResult = await this.sectionTypeController.Edit(lSectionTypeViewModel);

            RedirectToActionResult lViewResult = lResult as RedirectToActionResult;

            Assert.AreEqual("SectionType successfully updated", lViewResult.RouteValues["successMessage"]);

            await this.ReferenceServices.Received(1).UpdateSectionType(Arg.Is <SectionTypeDto>(dto => dto.Name == "England"));
        }