public void GetAllTrajecten() { EmptyLists(); treinreisRepository = new TrajectRepository(context); Assert.Equal(3, treinreisRepository.GetAllTrajecten().Count); }
public void UpdateTraject() { EmptyLists(); treinreisRepository = new TrajectRepository(context); Traject treinreis = new Traject(1, "naam", DateTime.Today, new Trein(1, "naam", 231, new Positie(1, 32, 42))); Assert.True(treinreisRepository.UpdateTraject(treinreis)); }
public void CreateTraject() { EmptyLists(); treinreisRepository = new TrajectRepository(context); Traject treinreis = new Traject(5, "naam", DateTime.Today, new Trein(5, "naam", 231, new Positie(1, 32, 42))); Assert.Equal(5, treinreisRepository.CreateTraject(treinreis)); }
public void GetTrajectbyId() { EmptyLists(); treinreisRepository = new TrajectRepository(context); Traject treinreis = new Traject(1, "naam", DateTime.Today, new Trein(1, "naam", 231, new Positie(1, 32, 42))); Assert.Equal(treinreis.Id, treinreisRepository.GetTrajectbyId(1).Id); Assert.Equal("naam", treinreis.Naam); }
public HomeController(IConfiguration configuration) { ticketContext = new MSSQLTicketContext(configuration.GetConnectionString("DefaultConnection")); ticketRepo = new TicketRepository(ticketContext); ticketConverter = new TicketViewModelConverter(); stationContext = new MSSQLStationContext(configuration.GetConnectionString("DefaultConnection")); stationRepo = new StationRepository(stationContext); stationConverter = new StationViewModelConverter(); trajectContext = new MSSQLTrajectContext(configuration.GetConnectionString("DefaultConnection")); trajectRepo = new TrajectRepository(trajectContext); trajectConverter = new TrajectViewModelConverter(); }
public void CreateTrajectTest() { IQueryable <Cursus> cursussen = new List <Cursus>() { new Cursus() { Titel = "dotNET cursus", Type = ".NET", Prijs = 15.45, Categorie = "Cursus", IsBuyable = true, Beschrijving = "Some example text some ...", LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", FotoURLCard = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg", OrderNumber = 1 }, new Cursus() { Titel = "dotNET cursus 2", Type = ".NET", Prijs = 18.45, IsBuyable = true, Beschrijving = "Some example text some ...", Categorie = "Cursus", LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", FotoURLCard = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg", OrderNumber = 2 } }.AsQueryable(); var traject = new Traject() { Titel = "dotNET cursus 2", Type = ".NET", Prijs = 18.45, Cursussen = cursussen.ToList(), IsBuyable = true, Beschrijving = "Some example text some ...", Categorie = "Cursus", LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", FotoURLCard = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg" }; // Arrange - We're mocking our dbSet & dbContext // in-memory data IQueryable <Traject> trajecten = new List <Traject>() { new Traject() { Titel = "dotNET traject", Type = ".NET", Prijs = 15.45, Categorie = "Traject", IsBuyable = false, Beschrijving = "Some example text some ...", LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", FotoURLCard = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg", OrderNumber = 1 }, new Traject() { Titel = "dotNET traject 2", Type = ".NET", Prijs = 18.45, IsBuyable = true, Beschrijving = "Some example text some ...", Categorie = "Traject", LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", FotoURLCard = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg", OrderNumber = 2 } }.AsQueryable(); var mockSetTraject = new Mock <DbSet <Traject> >(); mockSetTraject.As <IQueryable <Traject> >().Setup(m => m.Provider).Returns(trajecten.Provider); mockSetTraject.As <IQueryable <Traject> >().Setup(m => m.Expression).Returns(trajecten.Expression); mockSetTraject.As <IQueryable <Traject> >().Setup(m => m.ElementType).Returns(trajecten.ElementType); mockSetTraject.As <IQueryable <Traject> >().Setup(m => m.GetEnumerator()).Returns(trajecten.GetEnumerator()); var mockSetCursus = new Mock <DbSet <Cursus> >(); mockSetCursus.As <IQueryable <Cursus> >().Setup(m => m.Provider).Returns(cursussen.Provider); mockSetCursus.As <IQueryable <Cursus> >().Setup(m => m.Expression).Returns(cursussen.Expression); mockSetCursus.As <IQueryable <Cursus> >().Setup(m => m.ElementType).Returns(cursussen.ElementType); mockSetCursus.As <IQueryable <Cursus> >().Setup(m => m.GetEnumerator()).Returns(cursussen.GetEnumerator()); var mockContext = new Mock <DatabaseContext>(); mockContext.Setup(m => m.Trajecten).Returns(mockSetTraject.Object); mockContext.Setup(m => m.Cursussen).Returns(mockSetCursus.Object); var repo = new TrajectRepository(mockContext.Object, contextFilter); repo.AddTraject(traject); // Assert mockSetTraject.Verify(m => m.Add(It.IsAny <Traject>()), Times.Once); }
public TrajectController(IConfiguration configuration) { context = new MSSQLTrajectContext(configuration.GetConnectionString("DefaultConnection")); repo = new TrajectRepository(context); converter = new TrajectViewModelConverter(); }