public SessionControllerTest() { _lidRepostiory = new Mock <ILidRepository>(); _context = new DummyDbContext(); _controller = new SessionController(_lidRepostiory.Object); _sessie = new SessionState(); }
public PeopleController(DummyDbContext context) { _context = context; var per = new Person { Id = 1, Name = "Per", BirthDate = new DateTime(1980, 1, 1), IsMale = true }; var pål = new Person { Id = 2, Name = "Pål", BirthDate = new DateTime(1950, 1, 1), IsMale = true }; var lise = new Person { Id = 3, Name = "Lise", BirthDate = new DateTime(1950, 1, 1), IsMale = false }; per.Father = pål; per.Mother = lise; _people = new List <Person>(); _people.Add(per); _people.Add(pål); _people.Add(lise); }
public KlantTest() { _context = new DummyDbContext(); klantMetTweeReservaties = _context.Peter; klantZonderReservaties = _context.Piet; jaarVanReservaties = _context.Dag.Year; }
private DummyDbContext GetDbContext() { var builder = new DbContextOptionsBuilder <DummyDbContext>(); builder.UseInMemoryDatabase(Guid.NewGuid().ToString()); var options = builder.Options; var dbContext = new DummyDbContext(options); dbContext.Users.Add(new User { Id = 1, FirstName = "First", LastName = "Last" }); dbContext.Users.Add(new User { Id = 2, FirstName = "First", LastName = "Last" }); dbContext.SaveChanges(); return(dbContext); }
public SessieTest() { _context = new DummyDbContext(); _sessie = _context.sessie1; _gebruiker = _context.Jan; _inschrijvingen = _context.sessie1.Inschrijvingen; }
public VergaderruimteTest() { _context = new DummyDbContext(); _vergaderruimte = _context.Vergaderruimte; _klantMetVierReservaties = _context.Jan; _klantMetTweeReservaties = _context.Peter; _klantZonderReservaties = _context.Piet; }
public TrainingControllerTest() { _gymnastsRepo = new Mock <IGymnastRepo>(); _trainingRepo = new Mock <ITrainingRepo>(); _categoryRepo = new Mock <ICategoryRepo>(); _controller = new TrainingController(_gymnastsRepo.Object, _trainingRepo.Object, _categoryRepo.Object); _context = new DummyDbContext(); }
private MessageData GetMessageData() { var options = DbHelper.GetDbContextOptions(); using (var context = new DummyDbContext(options)) { return(context.MessageDatas.FirstOrDefault()); } }
private static void DeleteAllExistingData() { var options = DbHelper.GetDbContextOptions(); using (var context = new DummyDbContext(options)) { context.MessageDatas.RemoveRange(context.MessageDatas); context.SaveChanges(); } }
private async Task <int> AddAPingAsync(DbContextOptions <DummyDbContext> options) { //C# 8 :) await using var context = new DummyDbContext(options); var repository = new PingRepository(context); var ping = new Ping(); await repository.AddAsync(ping, CancellationToken.None).ConfigureAwait(false); return(ping.Id); }
public TicketControllerTest() { _dummyContext = new DummyDbContext(); _ticketTypeRepository = new Mock <ITicketTypeRepository>(); _gebruikerRepository = new Mock <IGebruikerRepository>(); _notyf = new Mock <INotyfService>(); _controller = new TicketController(_ticketTypeRepository.Object, _gebruikerRepository.Object, _notyf.Object) { TempData = new Mock <ITempDataDictionary>().Object }; }
public SessieControllerTest() { huidigeMaand = DateTime.Now.Month; _context = new DummyDbContext(); _sessieRepo = new Mock <ISessieRepository>(); _userRepo = new Mock <IGebruikerRepository>(); _controller = new SessieController(_sessieRepo.Object, _userRepo.Object) { TempData = new Mock <ITempDataDictionary>().Object }; }
public VerantwoordelijkeTest() { _context = new DummyDbContext(); _admin = _context.admin; _organizer1 = _context.organizer1; _organizer2 = _context.organizer2; hedenSessie = _context.hedenSessie; verledenSessie = _context.verledenSessie; }
public HomeControllerTest() { var httpcontext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpcontext, Mock.Of <ITempDataProvider>()); _context = new DummyDbContext(); _lidRepository = new Mock <ILidRepository>(); _controller = new HomeController(_lidRepository.Object) { TempData = tempData }; _sessie = new SessionState(); }
public void SqliteSqlGeneratorTest() { using (DbConnection connection = new SQLiteConnection("FullUri=file::memory:")) { // This is important! Else the in memory database will not work. connection.Open(); using (var context = new DummyDbContext(connection)) { // ReSharper disable once UnusedVariable Player fo = context.Set <Player>().FirstOrDefault(); Assert.AreEqual(RemoveLineEndings(ReferenceSql), RemoveLineEndings(generatedSql)); } } }
public void SqliteSqlGeneratorTest() { using (DbConnection connection = new SQLiteConnection("data source=:memory:")) { // This is important! Else the in memory database will not work. connection.Open(); using (var context = new DummyDbContext(connection)) { // ReSharper disable once UnusedVariable Player fo = context.Set <Player>().FirstOrDefault(); Assert.IsTrue(string.Equals(ReferenceSql.Trim(), generatedSql.Trim(), StringComparison.OrdinalIgnoreCase)); } } }
public UserControllerTest() { _dummyContext = new DummyDbContext(); _mockUserRepository = new Mock <IUserRepository>(); _jarne = _dummyContext.Jarne; _newJarne = _jarne; _newJarne.FirstName = "Bob"; _mockUserRepository.Setup(c => c.GetAll()).Returns(_dummyContext.Users); _mockUserRepository.Setup(c => c.GetById(_jarne.UserId)).Returns(_jarne); _mockUserRepository.Setup(c => c.GetByEmail(_jarne.Email)).Returns(_jarne); _mockUserRepository.Setup(c => c.Update(_newJarne)).Returns(_newJarne); _userController = new UserController(_mockUserRepository.Object) { }; }
private static async Task <List <Item> > SeedData(DummyDbContext db, int total) { var items = new List <Item>(); for (int i = 1; i <= total; i++) { int number = i; var item = new Item { Id = number }; items.Add(item); db.Items.Add(item); } await db.SaveChangesAsync(CancellationToken.None); return(items); }
public PostControllerTest() { _dummyContext = new DummyDbContext(); _mockUserRepository = new Mock <IUserRepository>(); _mockPostRepository = new Mock <IPostRepository>(); _post1 = _dummyContext.Post1; _jarne = _dummyContext.Jarne; _mockUserRepository.Setup(c => c.GetAll()).Returns(_dummyContext.Users); _mockUserRepository.Setup(c => c.GetById(_jarne.UserId)).Returns(_jarne); _mockPostRepository.Setup(a => a.GetAll()).Returns(_dummyContext.Posts); _mockPostRepository.Setup(a => a.GetById(_post1.PostId)).Returns(_post1); _postController = new PostController(_mockPostRepository.Object, _mockUserRepository.Object) { }; }
public FilmControllerTest() { _context = new DummyDbContext(); _filmRepository = new Mock <IFilmRepository>(); _customerRepository = new Mock <ICustomerRepository>(); _controller = new FilmsController(_filmRepository.Object, _customerRepository.Object); //deze zijn nodig om User.Identity.Name correct te mocken var identity = new GenericIdentity("*****@*****.**"); var principal = new ClaimsPrincipal(identity); _controllerContext = new DefaultHttpContext() { User = principal }; _controller.ControllerContext = new ControllerContext() { HttpContext = _controllerContext }; }
public void GetReportedUsers_WithLimitAndOffset_RetrievesExpectedUsersInAllCases(int limit, int offset, List <UserShortVersion> expected) { //arrange using (DummyDbContext ctx = new DummyDbContext()) { IAdminRepoTest adminRepo = new AdminRepo(); //act List <UserShortVersion> actual = adminRepo.GetAdminUsersWithDbContextAsync(ctx, limit, offset); //assert Assert.Equal(expected.Count, actual.Count); for (int i = 0; i < actual.Count; i++) { Assert.Equal(expected[i].UserId, actual[i].UserId); Assert.Equal(expected[i].UserFullName, actual[i].UserFullName); } } }
public LidControllerTest() { var httpcontext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpcontext, Mock.Of <ITempDataProvider>()); _lidRepository = new Mock <ILidRepository>(); _controller = new LidController(_lidRepository.Object) { TempData = tempData }; _context = new DummyDbContext(); _model = new LidViewModel(_context.Lid1); _modelSessie = new LidViewModelSession(_context.Lid1); _sessie = new SessionState(); lid = _context.Lid1; vm = new LidViewModel() { Achternaam = "gertjan", Voornaam = "peer", Land = lid.Land, Lessen = lid.Lessen, Postcode = lid.PostCode, Busnummer = lid.Busnummer, Email = lid.Email, EmailOuders = lid.EmailOuders, GeboorteDatum = lid.GeboorteDatum, Geslacht = lid.Geslacht, Graad = lid.Graad, GSM = lid.GSM, Huisnummer = lid.Huisnummer, Rijksregisternummer1 = lid.Rijksregisternummer.Substring(0, 2), Rijksregisternummer2 = lid.Rijksregisternummer.Substring(3, 2), Rijksregisternummer3 = lid.Rijksregisternummer.Substring(6, 2), Rijksregisternummer4 = lid.Rijksregisternummer.Substring(9, 3), Rijksregisternummer5 = lid.Rijksregisternummer.Substring(13, 2), Roltype = lid.Roltype, Stad = lid.Stad, StraatNaam = lid.StraatNaam, Telefoon = lid.Telefoon, Wachtwoord = lid.Wachtwoord }; }
public async Task CreatePing_AndReturn_NewId() { //Arrange var builder = new DbContextOptionsBuilder <DummyDbContext>(); builder.UseInMemoryDatabase(Guid.NewGuid().ToString()); //Act int pingId = await AddAPingAsync(builder.Options); await using (var context = new DummyDbContext(builder.Options)) { var repository = new PingRepository(context); Ping ping = await repository.GetByIdAsync(pingId, CancellationToken.None); //Assert Assert.Equal(ping.Id, pingId); }; }
public ReservatieControllerTest() { _context = new DummyDbContext(); _vergaderruimteRepository = new Mock <IVergaderruimteRepository>(); _kortingRepository = new Mock <IKortingRepository>(); _cateringRepository = new Mock <ICateringRepository>(); _controller = new ReservatieController(_vergaderruimteRepository.Object, _cateringRepository.Object, _kortingRepository.Object) { TempData = new Mock <ITempDataDictionary>().Object }; model = new ReservatieViewModel(_context.Vergaderruimte) { AantalPersonen = 10, BeginUur = 10, Dag = _context.Dag.AddDays(14), CateringId = 3, StandaardCatering = true, Duur = 2 }; }
public void GetLastMessagesForUser_WithOffset_RetrievesExpectedUsersWithMessages_InAllCases(int userId, int offset, List <UserShortVersionWithMessage> expected) { //arrange using (DummyDbContext ctx = new DummyDbContext()) { IChatRepoTest chatRepo = new ChatRepo(); //act List <UserShortVersionWithMessage> actual = chatRepo.GetLastMessagesForUserWithDbContext(ctx, userId, offset); //assert Assert.Equal(expected.Count, actual.Count); for (int i = 0; i < actual.Count; i++) { Assert.Equal(expected[i].UserId, actual[i].UserId); Assert.Equal(expected[i].UserFullName, actual[i].UserFullName); Assert.Equal(expected[i].Message.Id, actual[i].Message.Id); } } }
public OefeningControllerTest() { var httpcontext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpcontext, Mock.Of <ITempDataProvider>()); _context = new DummyDbContext(); _oefeningRepository = new Mock <IOefeningRepository>(); _lidRepository = new Mock <ILidRepository>(); _mailRepository = new Mock <IMailRepository>(); _controller = new OefeningController(_oefeningRepository.Object, _lidRepository.Object, _mailRepository.Object) { TempData = tempData }; _model = new _CommentsViewModel() { Comments = "Dit is de model comment" }; _sessie = new SessionState(); _sessie.VeranderHuidigLid(_context.Lid1); }
public ContractControllerTest() { _dummyContext = new DummyDbContext(); _ContractTypeRepository = new Mock <IContractTypeRepository>(); _GebruikerRepository = new Mock <IGebruikerRepository>(); _TicketTypeRepository = new Mock <ITicketTypeRepository>(); _notyf = new Mock <INotyfService>(); _controller = new ContractController(_GebruikerRepository.Object, _ContractTypeRepository.Object, _notyf.Object) { TempData = new Mock <ITempDataDictionary>().Object }; model = new ContractEditViewModel(_dummyContext.ContractPiet1) { ContractTitel = "", StartDatum = _dummyContext.Dag.AddDays(14), DoorloopTijd = 1, ContractTypeId = 1 }; }
public SessieControllerTest() { _context = new DummyDbContext(); _feedbackRepository = new Mock <IFeedbackRepository>(); _gebruikerRepository = new Mock <IGebruikerRepository>(); _inschrijvingRepository = new Mock <IInschrijvingRepository>(); _sessiekalenderRepository = new Mock <ISessieKalenderRepository>(); _sessieRepository = new Mock <ISessieRepository>(); _controller = new SessieController(_sessieRepository.Object, _gebruikerRepository.Object, _inschrijvingRepository.Object, _feedbackRepository.Object, _userManager) { TempData = new Mock <ITempDataDictionary>().Object }; model = new SessieDetailsViewModel(_context.sessie1) { Beschrijving = "Linux sucks", Datum = _context.dag.ToString(), Id = 3, Titel = "Why Linux sucks", OpenPlaatsen = 20 }; }
public RegisseurTest() { _context = new DummyDbContext(); }
public CustomerTest() { _context = new DummyDbContext(); }