public async Task HostCanCreateAddRoomAndDates() { var token = await GetHostToken(); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token); var data = new PropertyCreateDTO { Name = "Test31", Country = "Test31", Address = "Test31", Description = "Test31", Type = "Hotel", }; var getResponse = await _client.PostAsJsonAsync("/api/v1/property", data); getResponse.EnsureSuccessStatusCode(); var property = JsonConvert.DeserializeObject <PropertyDTO>(await getResponse.Content.ReadAsStringAsync()); Assert.NotNull(property); var postRoom = await _client.PostAsJsonAsync("/api/v1/room", new RoomDTO { PropertyId = property !.Id, Name = "Room", Size = 22, AdultsOccupancy = 2, ChildOccupancy = 2, Description = "test", FacilityDtos = null, BedTypes = new [] { "1 large" }, });
public async Task HostCanCRUDHisProperty() { var token = await GetHostToken(); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token); var property = new PropertyCreateDTO { Name = "Test4", Country = "Test4", Address = "Test4", Description = "Test4", Type = "Hotel", }; var getResponse = await _client.PostAsJsonAsync("/api/v1/property", property); getResponse.EnsureSuccessStatusCode(); var data = JsonConvert.DeserializeObject <PropertyDTO>(await getResponse.Content.ReadAsStringAsync()); Assert.NotEmpty(data?.Address); Assert.NotNull(data?.AppUserId); Assert.IsType <Guid>(data?.Id); var userId = data !.AppUserId; var propertyId = data?.Id; var putProperty = new PropertyCreateDTO { Name = data !.Name, Country = data !.Country, Address = data !.Address, Description = data !.Description, Type = "Hostel", Id = propertyId }; var putResponse = await _client.PutAsJsonAsync($"/api/v1/property/{propertyId}", putProperty); getResponse.EnsureSuccessStatusCode(); var updated = JsonConvert.DeserializeObject <PropertyCreateDTO>(await putResponse.Content.ReadAsStringAsync()); Assert.NotSame(property.Type, updated !.Type); Assert.True(updated?.Type == "Hostel"); var deleteResponse = await _client.DeleteAsync($"/api/v1/property/{propertyId}"); deleteResponse.EnsureSuccessStatusCode(); var ensureDeleted = await _client.GetAsync($"/api/v1/property/{propertyId}"); ensureDeleted.StatusCode.Should().Be(StatusCodes.Status404NotFound); }
public async Task HostCanCreateProperty() { var token = await GetHostToken(); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token); var property = new PropertyCreateDTO { Name = "Test3", Country = "Test3", Address = "Test3", Description = "Test3", Type = "Hotel", }; var getResponse = await _client.PostAsJsonAsync("/api/v1/property", property); getResponse.EnsureSuccessStatusCode(); var data = JsonConvert.DeserializeObject <PropertyDTO>(await getResponse.Content.ReadAsStringAsync()); Assert.NotEmpty(data?.Address); Assert.NotNull(data?.AppUserId); Assert.IsType <Guid>(data?.Id); }
public Property MapPropertyCreateView(PropertyCreateDTO inObject) => Mapper.Map <Property>(inObject);