public void Delete_Existing_Widget_NotFound()
        {
            var options = new DbContextOptionsBuilder <WidgetContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            using var context = new WidgetContext(options);
            var w1 = new Widget {
                Id = id1, Name = GetRandomString(), Shape = GetRandomString()
            };
            var w2 = new Widget {
                Id = id2, Name = GetRandomString(), Shape = GetRandomString()
            };
            var w3 = new Widget {
                Id = id3, Name = GetRandomString(), Shape = GetRandomString()
            };

            context.Widgets.Add(w1);
            context.Widgets.Add(w2);
            context.Widgets.Add(w3);
            context.SaveChanges();

            // workaround for EF Core tracking issue 12459. See:
            // https://github.com/aspnet/EntityFrameworkCore/issues/12459
            context.Entry(w1).State = EntityState.Detached;
            context.Entry(w2).State = EntityState.Detached;
            context.Entry(w3).State = EntityState.Detached;
            context.SaveChanges();

            Guid id = Guid.NewGuid(); // not in database!

            var controller   = new WidgetController(context);
            var actionResult = controller.Delete(id).Result;
            var result       = actionResult as NotFoundResult;

            Assert.IsNotNull(result);
            Assert.AreEqual(404, result.StatusCode);
        }
        public void WidgetController_DeletePost_NullReturnUrlRedirectToRouteResult()
        {
            var textWidget = new TextWidget();

            _widgetController.Delete(textWidget, null).Should().BeOfType <RedirectToRouteResult>();
        }