コード例 #1
0
        public async Task Update_should_modify_video()
        {
            //Arrange
            EditVideoRequest request = TestDataFactory.CreateEditVideoRequest();

            request.KindId  = new Guid("2fd37626-0b1d-4d51-a243-0bc4266a7a99");
            request.GenreId = new Guid("9dc0d6f2-a3d8-41a9-8393-d832c0b7a6e9");
            Guid Id = new Guid("eaa0B9d4-4A2d-496e-8a68-a36cd0758abb");

            HttpClient    client      = Factory.CreateClient();
            StringContent httpContent = new StringContent(JsonConvert.SerializeObject(request),
                                                          Encoding.UTF8, "application/json");

            //Act
            HttpResponseMessage response = await client.PutAsync($"{Url}/{Id}", httpContent);

            //Assert
            response.EnsureSuccessStatusCode();
            string responseContent = await response.Content.ReadAsStringAsync();

            Video responseEntity = JsonConvert.DeserializeObject <Video>(responseContent);

            responseEntity.Should().BeEquivalentTo(request, o => o.Excluding(x => x.Id));
            Assert.Equal(Id, responseEntity.Id);
        }
コード例 #2
0
        public void Should_have_error_when_Duration_is_lower_than_0()
        {
            EditVideoRequest addVideoRequest = TestDataFactory.CreateEditVideoRequest();

            addVideoRequest.Duration = -1;

            Validator.ShouldHaveValidationErrorFor(x => x.Duration, addVideoRequest);
        }
コード例 #3
0
        public void Should_not_have_error_when_Duration_is_null()
        {
            EditVideoRequest addVideoRequest = TestDataFactory.CreateEditVideoRequest();

            addVideoRequest.Duration = null;

            Validator.ShouldNotHaveValidationErrorFor(x => x.Duration, addVideoRequest);
        }
コード例 #4
0
        public void Should_have_error_when_GenreId_is_null()
        {
            EditVideoRequest addVideoRequest = TestDataFactory.CreateEditVideoRequest();

            addVideoRequest.GenreId = Guid.Empty;

            Validator.ShouldHaveValidationErrorFor(x => x.GenreId, addVideoRequest);
        }