public static void AllFieldsPresentAndWithinValidationRules_ModelStateValid()
        {
            var sut               = new CreateContentResourceBuilder().Build();
            var context           = new ValidationContext(sut, null);
            var validationResults = new List <ValidationResult>();

            var valid = Validator.TryValidateObject(sut, context, validationResults, true);

            Assert.True(valid);
        }
Beispiel #2
0
        public static async Task CreateContentRightAsync_ReturnsBadRequestResult_WhenResourceIsInvalid(int id, string text, string expectedErrorMessage)
        {
            // Arrange
            var data = text.ConvertToBase64FromUTF8String();
            CreateContentResource resource = new CreateContentResourceBuilder().WithData(data).Build();
            ContentResponse       response = new ContentResponse(expectedErrorMessage);
            var sutDiffController          = SetupDiffControllerForUpsertContentAsync(response);

            // Act
            var result = await sutDiffController.CreateContentRightAsync(id, resource);

            // Assert
            Assert.IsType <BadRequestObjectResult>(result);
        }
Beispiel #3
0
        private async Task <HttpResponseMessage> CreateContentAsync(Content content, ContentDirection direction)
        {
            CreateContentResource resource = new CreateContentResourceBuilder().WithData(content.LeftContentData).Build();

            if (direction == ContentDirection.Right)
            {
                resource = new CreateContentResourceBuilder().WithData(content.RightContentData).Build();
            }

            var url      = $"/v1/diff/{content.Id}/{direction}";
            var response = await Client.PostAsync(url, resource.ToStringContent());

            return(response);
        }
Beispiel #4
0
        public static async Task CreateContentRightAsync_ReturnsOkResult_WhenResourceIsValid(int id, string text)
        {
            // Arrange
            var data = text.ConvertToBase64FromUTF8String();
            CreateContentResource resource    = new CreateContentResourceBuilder().WithData(data).Build();
            Content         content           = new ContentBuilder().WithId(id).WithRightContent(data).Build();
            ContentResponse response          = new ContentResponse(content);
            var             sutDiffController = SetupDiffControllerForUpsertContentAsync(response);

            // Act
            var result = await sutDiffController.CreateContentRightAsync(id, resource);

            // Assert
            Assert.IsType <OkObjectResult>(result);
        }