public void TestAddMethodWithTwoPositiveNumbers() { //Arrange - instan. classes etc. var testService = new DataTestService(); //Act - Call the method to test int result = testService.Add(2, 5); //Assert - Check if you get the right result back Assert.Equal(7, result); }
public void AddNewMadbestillingToDatabase() { IMadbestillingRepository testRepo = DataTestService.GetInMemoryRepo(); var madbestillings = new Madbestillings() { MenuTekst = "Burger", AntalBestillinger = 1 }; testRepo.Save(madbestillings); Assert.Single(testRepo.Get()); Assert.Equal(madbestillings.MenuTekst, testRepo.Get(1).MenuTekst); }
public void DeleteMadbestillingFromDatabase() { IMadbestillingRepository testrepo = DataTestService.GetInMemoryRepo(); var madbestillings = new Madbestillings() { MenuTekst = "Burger", AntalBestillinger = 1 }; testrepo.Save(madbestillings); testrepo.Delete(testrepo.Get(1).MadbestillingId); Assert.Empty(testrepo.Get()); }
public void TestIndexMethodReturnsObjects() { // Arrange var mockRepo = new Mock <IMadmenuRepository>(); var mockMenuRepo = new Mock <IMadbestillingRepository>(); mockRepo.Setup(repo => repo.Get()) .Returns(DataTestService.GetTestMadmenu()); var controller = new MadMenuController(mockMenuRepo.Object, mockRepo.Object); // Act var result = controller.Index(); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <MadMenu> >( viewResult.ViewData.Model); Assert.Equal(2, model.Count()); }
public void MadbestillingWithSameIDOverWritesCurrentMadbestillingInDB() { IMadbestillingRepository testrepo = DataTestService.GetInMemoryRepo(); var madbestillings = new Madbestillings() { MenuTekst = "Burger", AntalBestillinger = 1 }; testrepo.Save(madbestillings); var sameMadbestilling = testrepo.Get(1); sameMadbestilling.MenuTekst = "Burger2"; testrepo.Save(sameMadbestilling); Assert.Single(testrepo.Get()); Assert.Equal(sameMadbestilling.MenuTekst, testrepo.Get(1).MenuTekst); }