예제 #1
0
        public virtual async Task <PieceOfWork> Save(PieceOfWork pieceOfWork)
        {
            await _pieceOfWorkRepository.CreateOrUpdateAsync(pieceOfWork);

            await _pieceOfWorkRepository.SaveChangesAsync();

            return(pieceOfWork);
        }
        public async Task GetAllPieceOfWorks()
        {
            // Initialize the database
            await _pieceOfWorkRepository.CreateOrUpdateAsync(_pieceOfWork);

            await _pieceOfWorkRepository.SaveChangesAsync();

            // Get all the pieceOfWorkList
            var response = await _client.GetAsync("/api/piece-of-works?sort=id,desc");

            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var json = JToken.Parse(await response.Content.ReadAsStringAsync());

            json.SelectTokens("$.[*].id").Should().Contain(_pieceOfWork.Id);
            json.SelectTokens("$.[*].title").Should().Contain(DefaultTitle);
            json.SelectTokens("$.[*].description").Should().Contain(DefaultDescription);
        }