public void RoomCreatePost_ValidFormCollection_ReturnsRedirectToActionValidModel() { // Arrange var mockUoW = new Mock <IUnitOfWork>(); var mockRoomRepository = new Mock <IRepository <Room> >(); var httpRequest = new Mock <HttpRequest>(); var httpContext = new Mock <HttpContext>(); var connection = new Mock <ConnectionInfo>(); var ipAddress = IPAddress.Parse("127.0.0.1"); httpContext.Setup(x => x.Request).Returns(httpRequest.Object); httpContext.Setup(x => x.Request.HttpContext).Returns(httpContext.Object); httpContext.Setup(x => x.Request.HttpContext.Connection).Returns(connection.Object); httpContext.Setup(x => x.Request.HttpContext.Connection.RemoteIpAddress).Returns(ipAddress); var controllerContext = new ControllerContext() { HttpContext = httpContext.Object, }; var controller = new RoomController(mockUoW.Object) { ControllerContext = controllerContext }; var fields = new Dictionary <string, StringValues>(); var formCollection = new FormCollection(fields); mockUoW.Setup(x => x.RoomRepository.Insert(It.IsAny <Room>())); // Act var result = controller.Create(formCollection) as RedirectToActionResult; // Assert Assert.AreEqual("Index", result.ActionName); }
public void RoomCreateGet_TwoPlacesWithoutRoomsFound_ReturnViewResultModelWithTwoPlaces() { // Arrange var mockUoW = new Mock <IUnitOfWork>(); var controller = new RoomController(mockUoW.Object); var place1 = CreatePlaceWithoutRooms(); var place2 = CreatePlaceWithoutRooms(); var listOfPlaces = new List <Place> { place1, place2 }; mockUoW .Setup(x => x.PlaceRepository.GetAll()) .Returns(listOfPlaces.AsQueryable()); // Act ViewResult result = controller.Create() as ViewResult; var roomDto = result.Model as RoomDto; // Assert Assert.AreEqual(2, roomDto.Places.Count); }
public void PrepareRequestedRoomRpc(int betChoice, int capacityChoice, List <FullUserInfo> userInfos, int myTurn) { DestroyLobby(); new RoomSettings(betChoice, capacityChoice, userInfos, myTurn); RoomController.Create(null).Forget(); }
public void Create_WhenCalled_ShouldNotReturnNull() { // Arrange RoomController controller = new RoomController(_userManager, _roomRepository, _timeTaskRepository, _authorizationService, _mapper); // Act ViewResult viewResult = controller.Create() as ViewResult; // Assert Assert.NotNull(viewResult); }
private void LoadAppropriateModules(ActiveRoomState activeRoomState) { if (activeRoomState == null) { new LobbyController(); Debug.Log("attempt to create and forget Lobby"); } else { new RoomSettings(activeRoomState); RoomController.Create(activeRoomState).Forget(); } }
public void RoomCreatePost_InvalidFormCollectionThrowsException_ReturnsErrorViewResult() { // Arrange var mockUoW = new Mock <IUnitOfWork>(); var controller = new RoomController(mockUoW.Object); var roomRepository = new Mock <IRepository <Reservation> >(); var formCollectionList = new List <KeyValuePair <string, Microsoft.Extensions.Primitives.StringValues> >(); mockUoW.Setup(x => x.RoomRepository.Insert(It.IsAny <Room>())); // Act ViewResult result = controller.Create(It.IsAny <IFormCollection>()) as ViewResult; // Assert Assert.AreEqual("Error", result.ViewName); }
public void RoomCreateGet_NoPlacesFound_ReturnViewResultModelWithNullPlaces() { // Arrange var mockUoW = new Mock <IUnitOfWork>(); var controller = new RoomController(mockUoW.Object); var listOfPlaces = new List <Place>(); mockUoW .Setup(x => x.PlaceRepository.GetAll()) .Returns(listOfPlaces.AsQueryable()); // Act ViewResult result = controller.Create() as ViewResult; var roomDto = result.Model as RoomDto; // Assert Assert.IsNull(roomDto.Places); }