Exemple #1
0
        public async void DoubleCreateRoomTest()
        {
            //Arrange
            var user = await _userService.NewRegistrationAsync("mail5", "pw5", "f");

            //Act
            await _roomService.CreateRoomAsync(user.Id, "ciao");

            //Assert
            await Assert.ThrowsAsync <GeneralException>(async() =>
            {
                await _roomService.CreateRoomAsync(user.Id, "ciao");
            });
        }
Exemple #2
0
        public async Task <UserDto> NewRegistration([FromHeader] string mail, [FromHeader] string password, [FromHeader] string gender)
        {
            //new DbReset();
            var user = await _userService.NewRegistrationAsync(mail, password, gender);

            if (!await _roomService.ExistRoomAsync("DefaultRoom"))
            {
                await _roomService.CreateRoomAsync(user.Id, "DefaultRoom");
            }
            await _roomService.SudoAddPersonToRoomAsync("DefaultRoom", mail);

            return(user.AsDto());
        }
Exemple #3
0
        public async void AddPositionTest()
        {
            //Arrange
            var user = await _userService.NewRegistrationAsync("mail", "pw", "m");

            var roomId = await _roomService.CreateRoomAsync(user.Id, "room1");

            await _positionService.AddPositionAsync(user.Id, 10, 20);

            //Act
            var position = await _positionRepo.GetPositionAsync(user.Id);

            //Assert
            Assert.Equal(10, position.X);
            Assert.Equal(20, position.Y);
        }
        public async Task <ActionResult <bool> > Create([FromBody] NewRoom newRoom)
        {
            var tenant = (await _tenantService.GetTenantFromHostAsync());

            if (tenant != null)
            {
                Console.WriteLine($"creating room for {tenant.Id} : {tenant.Name}");
                using (var context = _tenantService.CreateContext(tenant))
                {
                    var roomService = new RoomService(context);
                    return(Ok(await roomService.CreateRoomAsync(newRoom)));
                }
            }

            return(BadRequest("Tenant doesn't exist"));
        }
 public async Task <RoomDto> CreateRoom([FromHeader] string id, string roomName)
 {
     return((await _roomService.CreateRoomAsync(_authorizationContext.User.Id, roomName)).AsDto());
 }