public void CanGetRoomInDatabase() { // Arrange Everything We Need For Our Unit Tests options = new DbContextOptionsBuilder <ApplicationDBContext>() .UseInMemoryDatabase(databaseName: "TestRevatureHousingData") .Options; testContext = new ApplicationDBContext(options); dummyRoomsData = new RoomDummyData(); dummyRooms = dummyRoomsData.RoomsList; testRoomRepository = new RoomRepository(testContext); testRoomController = new RoomsController(testRoomRepository); dummyConstantRoom = new Room() { RoomID = 12728 }; //Arrange Populate(); // Act var getRoomResult = testRoomController.GetRoom(5).Value; //Assert Assert.IsInstanceOfType(getRoomResult, typeof(Room)); // Clearing Changes ClearAllChanges(); }
public void CanGetAllRoomsInDatabase() { // Arrange Everything We Need For Our Unit Tests options = new DbContextOptionsBuilder <ApplicationDBContext>() .UseInMemoryDatabase(databaseName: "TestRevatureHousingData") .Options; testContext = new ApplicationDBContext(options); dummyRoomsData = new RoomDummyData(); dummyRooms = dummyRoomsData.RoomsList; testRoomRepository = new RoomRepository(testContext); testRoomController = new RoomsController(testRoomRepository); dummyConstantRoom = new Room() { RoomID = 12728 }; // Arrange // Adding all rooms to database Populate(); //Act var allRooms = testRoomController.GetRoom().Result.ToList(); var allDummyRooms = dummyRooms.Count; Assert.AreEqual(allRooms.Count, allDummyRooms); // Clearing Changes ClearAllChanges(); }
public async void Can_post_items() { using (_context) { var controller = new RoomsController(_context); Models.Room testdata = new Models.Room(); testdata.roomName = "testroom"; await controller.PostRoom(testdata); var room = controller.GetRoom(); var List = new List <Room>(); int Listcount = 0; foreach (Room data1 in room.Result.Value.ToList()) { List.Add(data1); Listcount++; } Assert.AreEqual(Listcount, List.Count); Assert.AreEqual("testroom", List[Listcount - 1].roomName); //Delete if (List.Count > 0) { var item = List[List.Count - 1]; await controller.DeleteRoom(item.roomID); } room = controller.GetRoom(); List = new List <Room>(); foreach (Room data1 in room.Result.Value.ToList()) { List.Add(data1); } Assert.AreEqual(Listcount - 1, List.Count); } }
public void GetRoomTest(Int32 id) { var result = _roomController.GetRoom(id); // Assert var content = Assert.IsAssignableFrom <RoomDto>(result.Value); Assert.Equal(id, content.Id); }
public async void Can_post_items() { using (_context) { SensorsController controller = new SensorsController(_context); RoomsController roomsController = new RoomsController(_context); var room = roomsController.GetRoom(); var RoomList = new List <Room>(); foreach (Room data1 in room.Result.Value.ToList()) { RoomList.Add(data1); } Models.Sensor testdata = new Models.Sensor(); testdata.servoSetting = "5"; testdata.roomID = RoomList[0].roomID; await controller.PostSensor(testdata); var sensor = controller.GetSensor(); var List = new List <Sensor>(); int Listcount = 0; foreach (var sensor1 in sensor.Result.Value.ToList()) { List.Add(sensor1); Listcount++; } Assert.AreEqual(Listcount, List.Count); Assert.AreEqual("5", List[Listcount - 1].servoSetting); //Delete if (List.Count > 0) { var item = List[List.Count - 1]; await controller.DeleteSensor(item.sensorID); } sensor = controller.GetSensor(); List = new List <Sensor>(); foreach (var sensor1 in sensor.Result.Value.ToList()) { List.Add(sensor1); } Assert.AreEqual(Listcount - 1, List.Count); } }
public void Should_GetRoom() { Room testRoom = new Room { Id = 1, Name = "Test5", Description = "Test", VenueId = 1, Columns = 10, Rows = 10, Isles = "{}" }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.Rooms.GetById(1)).Returns(testRoom); RoomsController controller = new RoomsController(mock.Object); var room = controller.GetRoom(1); Assert.IsType <OkObjectResult>(room); }
public async void Task2_GetById_Return_NotFoundResult() { //Arrange var roomId = "main room"; var projectId = 12; _context = new SDCContext(dbContextOptions); _controller = new RoomsController(_context); //Act var result = await _controller.GetRoom(roomId, projectId); //Assert Assert.IsType <NotFoundResult>(result); }
public void Can_get_items() { using (_context) { var controller = new RoomsController(_context); var room = controller.GetRoom(); var List = new List <Room>(); foreach (Room data1 in room.Result.Value.ToList()) { List.Add(data1); } Assert.AreEqual(List.Count, List.Count); } }