public void Should_GetRooms() { // mock UoW and repository data Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.Rooms.Get()).Returns(new List <Room> { new Room { Id = 1, Name = "Test1", Description = "Test", VenueId = 1, Columns = 10, Rows = 10, Isles = "{}" }, new Room { Id = 2, Name = "Test2", Description = "Test", VenueId = 1, Columns = 10, Rows = 10, Isles = "{}" }, new Room { Id = 3, Name = "Test3", Description = "Test", VenueId = 1, Columns = 10, Rows = 10, Isles = "{}" }, new Room { Id = 4, Name = "Test4", Description = "Test", VenueId = 1, Columns = 10, Rows = 10, Isles = "{}" }, new Room { Id = 5, Name = "Test5", Description = "Test", VenueId = 1, Columns = 10, Rows = 10, Isles = "{}" } } .AsQueryable()); RoomsController controller = new RoomsController(mock.Object); var rooms = controller.GetRooms(); Assert.True(rooms.Count() == 5); }
public void GetRoomsTest() { var result = _roomController.GetRooms(); // Assert var content = Assert.IsAssignableFrom <List <RoomDto> >(result.Value); Assert.Equal(3, content.Count()); }
public void Can_get_item() { using (var context = new Lab2Context(ContextOptions)) { var controller = new RoomsController(context); var item = controller.GetRooms(1); Assert.Equal("oll", item.Description); } }
public void Can_get_items() { using (var context = new Lab2Context(ContextOptions)) { var controller = new RoomsController(context); var items = controller.GetRooms().ToList(); Assert.Equal(3, items.Count); Assert.Equal(2, items[1].RoomID); Assert.Equal(500, items[2].Price); } }
public void Get_ShouldReturnTwoRooms() { ClearRoomsFromDatabase(); var controller = new RoomsController(context); context.Room.Add(new Room { id = 1, name = "Pokój 1", link = "https://localhost:4200/room/1" }); context.Room.Add(new Room { id = 2, name = "Pokój 2", link = "https://localhost:4200/room/2" }); context.SaveChanges(); IEnumerable <Room> result = controller.GetRooms(); Assert.Equal(2, result.Count()); }