コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,HardProperty")] SampleTestEntity SampleTestEntity)
        {
            if (id != SampleTestEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _service.UpdateSampleTestEntity(SampleTestEntity);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(SampleTestEntity));
        }
コード例 #2
0
        public void Update_SampleTestEntity()
        {
            var newEntity = new SampleTestEntity()
            {
                Name = "test entity", HardProperty = new string[] { "testA", "testB" }
            };
            int?returnId = _SampleEntityService.AddSampleTestEntity(newEntity).GetAwaiter().GetResult();

            Assert.IsNotNull(returnId, "Addition of entity caused error");

            newEntity.HardProperty = new string[] { "testA", "testB", "testC" };
            int?returnUpdateId = _SampleEntityService.UpdateSampleTestEntity(newEntity).GetAwaiter().GetResult();

            Assert.IsNotNull(returnUpdateId, "Entity could not be updated");
            Assert.Greater(returnUpdateId, 0, "Entity update count was not as expected");

            var resultEntity = _SampleEntityService.GetSampleTestEntity(1).GetAwaiter().GetResult();

            Assert.IsNotNull(resultEntity, "Entity was not avaialable and resulted as null");
            Assert.AreEqual(resultEntity.HardProperty.Count(), 3, "HardProperty item count was not as expected");
        }