public async void Delete_ValidDeletion_RedirectsToManage()
        {
            List<Company> companies = new List<Company>
            {
                new Company
                {
                    Id = new Guid("99D59A63-ADFC-4C4D-82EB-DC9FADC6371D"),
                    Name = "FirstCompany",
                    DevelopedGameProducts = new List<GameProduct>(),
                    PublishedGameProducts = new List<GameProduct>()
                }
            };

            Mock<IVeilDataAccess> dbStub = TestHelpers.GetVeilDataAccessFake();
            Mock<DbSet<Company>> companyDbSetStub = TestHelpers.GetFakeAsyncDbSet(companies.AsQueryable());
            companyDbSetStub.Setup(db => db.FindAsync(companies[0].Id)).ReturnsAsync(companies[0]);
            companyDbSetStub.Setup(db => db.Remove(It.IsAny<Company>()))
                .Returns<Company>(c => { companies.Remove(c); return c; });
            dbStub.Setup(db => db.Companies).Returns(companyDbSetStub.Object);

            CompaniesController controller = new CompaniesController(dbStub.Object);

            var result = await controller.Delete(companies[0].Id) as RedirectToRouteResult;

            Assert.That(result != null);

            Assert.That(result != null);
            Assert.That(result.RouteValues["action"], Is.EqualTo("Manage"));
            Assert.That(companies.Count, Is.EqualTo(0));
        }
        public void Delete_CompanyDoesNotExist_Throws404Exception()
        {
            List<Company> companies = new List<Company>
            {
                new Company
                {
                    Id = new Guid("99D59A63-ADFC-4C4D-82EB-DC9FADC6371D"),
                    Name = "FirstCompany",
                    DevelopedGameProducts = new List<GameProduct>(),
                    PublishedGameProducts = new List<GameProduct>()
                }
            };
            
            Mock<IVeilDataAccess> dbStub = TestHelpers.GetVeilDataAccessFake();
            Mock<DbSet<Company>> companyDbSetStub = TestHelpers.GetFakeAsyncDbSet(companies.AsQueryable());
            companyDbSetStub.Setup(db => db.Add(It.IsAny<Company>())).Callback<Company>(companies.Add);
            dbStub.Setup(db => db.Companies).Returns(companyDbSetStub.Object);

            CompaniesController controller = new CompaniesController(dbStub.Object);

            Assert.That(async () => await controller.Delete(new Guid("E1F95A79-5C5A-4BBC-BF88-DA4E2DC177B3")), Throws.InstanceOf<HttpException>().And.Matches<HttpException>(ex => ex.GetHttpCode() == 404));
        }
        public async void Delete_CompanyHasGameProducts_HasCorrectError()
        {
            List<Company> companies = new List<Company>
            {
                new Company
                {
                    Id = new Guid("99D59A63-ADFC-4C4D-82EB-DC9FADC6371D"),
                    Name = "FirstCompany",
                    DevelopedGameProducts = new List<GameProduct>
                    {
                        new PhysicalGameProduct()
                    },
                    PublishedGameProducts = new List<GameProduct>()
                }
            };

            Mock<IVeilDataAccess> dbStub = TestHelpers.GetVeilDataAccessFake();
            Mock<DbSet<Company>> companyDbSetStub = TestHelpers.GetFakeAsyncDbSet(companies.AsQueryable());
            companyDbSetStub.Setup(db => db.FindAsync(companies[0].Id)).ReturnsAsync(companies[0]);
            companyDbSetStub.Setup(db => db.Remove(It.IsAny<Company>()))
                .Returns<Company>(c => { companies.Remove(c); return c; });
            dbStub.Setup(db => db.Companies).Returns(companyDbSetStub.Object);

            CompaniesController controller = new CompaniesController(dbStub.Object);

            var result = await controller.Delete(companies[0].Id) as RedirectToRouteResult;

            Assert.That(result != null);

            var alerts = controller.TempData["AlertMessages"];
            Assert.That(alerts is List<AlertMessage>);

            AlertMessage message = ((List<AlertMessage>)alerts)[0];
            Assert.That(message.Message, Is.EqualTo($"{companies[0].Name} cannot be deleted because it has related products."));

            Assert.That(companies.Count, Is.EqualTo(1));
        }
        public void Delete_CompanyIsNull_Throws404Exception()
        {
            CompaniesController controller = new CompaniesController(null);

            Assert.That(async () => await controller.Delete(null), Throws.InstanceOf<HttpException>().And.Matches<HttpException>(ex => ex.GetHttpCode() == 404));
        }