Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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());
        }
Пример #4
0
        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());
        }
Пример #5
0
        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);
        }