public void CreateRoomInvokeTest()
        {
            RoomController controller = new RoomController();
            var            result     = controller.CreateRoom(new RoomInfo("test", Guid.Parse("F0BCA20B-E16E-48B5-9B55-5A5A3553BEB5"), false));

            Assert.IsNotNull(result.Name, "Name is null");
            Assert.IsNotNull(result.HostId, "Guid is null");
        }
        public async Task TestCreateRoom_ReturnsOk_Room()
        {
            mockRoomService.Setup(x => x.CreateRoom(It.IsAny <RoomConfiguration>(), It.IsAny <GameType>()))
            .Returns(roomHelper.roomChinese);
            roomController = new RoomController(mockRoomService.Object);
            var createRoomsResult = await roomController.CreateRoom(new RoomConfiguration());

            OkObjectResult result = createRoomsResult as OkObjectResult;

            Assert.NotNull(result);
            Assert.AreEqual(roomHelper.roomChinese, result.Value);
            Assert.AreEqual(200, result.StatusCode);
        }
        public void ShouldAddRoom()
        {
            // arrange
            RoomInfo RequestAddRoom = new RoomInfo
            {
                Id   = 1,
                Name = "TestDummyRoom1",
            };

            //act

            var result = controller.CreateRoom(RequestAddRoom);

            // assert
            Assert.IsNotNull(result);
        }
Beispiel #4
0
        private void btnCreateRoom_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBoxRoomID.Text) ||
                String.IsNullOrEmpty(textBoxPrice.Text) ||
                String.IsNullOrEmpty(textBoxBeds.Text) ||
                String.IsNullOrEmpty(textBoxRoomnumber.Text) ||
                String.IsNullOrEmpty(textBoxPeriod.Text))
            {
                Console.WriteLine("Skapa Rum1");
            }
            else
            {
                int parsedValue;
                if (!int.TryParse(textBoxPrice.Text, out parsedValue))
                {
                    labelRoom.Text = "Pris måste vara siffor";
                    return;
                }

                if (!int.TryParse(textBoxBeds.Text, out parsedValue))
                {
                    labelRoom.Text = "Antal sängar måste vara siffor";
                    return;
                }

                Room r = new Room();
                r.roomId     = textBoxRoomID.Text;
                r.price      = Int32.Parse(textBoxPrice.Text);
                r.beds       = Int32.Parse(textBoxBeds.Text);
                r.roomNumber = textBoxRoomnumber.Text;
                r.period     = textBoxPeriod.Text;
                r.available  = "y";

                RoomController RController = new RoomController();

                RController.CreateRoom(r);

                textBoxRoomID.Text     = "";
                textBoxPrice.Text      = "";
                textBoxBeds.Text       = "";
                textBoxRoomnumber.Text = "";
                textBoxPeriod.Text     = "";

                dataGridViewRoom.ClearSelection();
                buttonFindAllRooms.PerformClick();
            }
        }
Beispiel #5
0
        protected void lbSubmit_Click(object sender, EventArgs e)
        {
            //save the room
            var rc = new RoomController();

            if (txtRoomId.Text.Any())
            {
                var r = rc.GetRoom(new Guid(txtRoomId.Text), ModuleId);
                r.RoomName            = txtRoomName.Text.Trim();
                r.RoomDescription     = txtRoomDescription.Text.Trim();
                r.RoomPassword        = txtRoomPassword.Text.Trim();
                r.RoomWelcome         = txtRoomWelcome.Text.Trim();
                r.Private             = chkPrivateRoom.Checked;
                r.Enabled             = chkEnabled.Checked;
                r.ShowRoom            = chkShowRoom.Checked;
                r.LastUpdatedByUserId = UserId;
                r.LastUpdatedDate     = DateTime.UtcNow;

                rc.UpdateRoom(r);
            }
            else
            {
                var r = new Room
                {
                    RoomId              = Guid.NewGuid(),
                    RoomName            = txtRoomName.Text.Trim(),
                    RoomDescription     = txtRoomDescription.Text.Trim(),
                    RoomPassword        = txtRoomPassword.Text.Trim(),
                    RoomWelcome         = txtRoomWelcome.Text.Trim(),
                    Private             = chkPrivateRoom.Checked,
                    Enabled             = chkEnabled.Checked,
                    ShowRoom            = chkShowRoom.Checked,
                    CreatedByUserId     = UserId,
                    CreatedDate         = DateTime.UtcNow,
                    LastUpdatedByUserId = UserId,
                    LastUpdatedDate     = DateTime.UtcNow,
                    ModuleId            = ModuleId
                };
                rc.CreateRoom(r);
            }
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }
        public async Task CreateRoom_MakeCreateRoomRequest_ReturnsActionResultWithCreateRoomResponse()
        {
            _unitOfWork.Setup(u => u.UserRepository.AddAsync(It.IsAny <User>()));
            _unitOfWork.Setup(u => u.UserRepository.Update(It.IsAny <User>()));
            _unitOfWork.Setup(u => u.CommitAsync());
            _unitOfWork.Setup(u => u.RoomRepository.CreateAsync(It.IsAny <Room>()));
            _mapper.Setup(m => m.Map <RoomDto>(It.IsAny <Room>())).Returns(It.IsAny <RoomDto>());
            _configuration.Setup(c => c[It.IsAny <string>()]).Returns("godot_chat_backend_project_sample_key");


            var result = await _controller.CreateRoom(new CreateRoomRequest
            {
                Username        = "******",
                RoomDescription = "TestRoom"
            });

            _unitOfWork.Verify(u => u.UserRepository.AddAsync(It.IsAny <User>()));
            _unitOfWork.Verify(u => u.UserRepository.Update(It.IsAny <User>()));
            _unitOfWork.Verify(u => u.CommitAsync());
            _unitOfWork.Verify(u => u.RoomRepository.CreateAsync(It.IsAny <Room>()));

            Assert.That(result, Is.TypeOf <ActionResult <CreateRoomResponse> >());
        }