Exemple #1
0
 public ActionResult Delete(int id, IFormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         ServiceProviderRepository.DeleteProvider(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
        public void CanServiceProviderRepositoryDeleteProvider()
        {
            //arrange
            var testProvider = new ServiceProvider()
            {
                Id   = 10,
                Name = "NoHands McGee"
            };

            //act
            ServiceProviderRepository.Add(testProvider);
            ServiceProviderRepository.DeleteProvider(testProvider.Id);

            //assert
            var p = ServiceProviderRepository.Providers.FirstOrDefault(x => x.Id == testProvider.Id);

            Assert.Null(p);
        }
Exemple #3
0
        public void CanServiceProviderRepositoryDeleteProvider()
        {
            //arrange
            var mockSpaContext             = new Mock <SpaContext>(null);
            var mockReadOnlySpaContext     = new Mock <IReadOnlySpaContext>();
            ServiceProviderRepository repo = new ServiceProviderRepository(
                mockSpaContext.Object, mockReadOnlySpaContext.Object);
            var testProvider = new ServiceProvider()
            {
                Id   = 10,
                Name = "NoHands McGee"
            };

            //act
            repo.Add(testProvider);
            repo.DeleteProvider(testProvider.Id);

            //assert
            var p = repo.ServiceProviders.FirstOrDefault(x => x.Id == testProvider.Id);

            Assert.Null(p);
        }