Beispiel #1
0
        public void Validate_ResponseStreamNotAsExpected_ValidationFails()
        {
            // Arrange
            const string             fileId          = "fileId";
            MemoryStream             responseStream  = new MemoryStream(Encoding.UTF8.GetBytes("my content"));
            MemoryStream             expectedStream  = new MemoryStream();
            ResponseContentValidator validator       = new ResponseContentValidator(fileId);
            ResourceManagerMock      resourceManager = new ResourceManagerMock {
                { fileId, expectedStream }
            };
            ResponseDataMock responseData = new ResponseDataMock {
                ResponseStream = responseStream
            };

            // Act
            ValidationResult validationResult = validator.Validate(responseData, resourceManager, null);

            // Assert
            Assert.IsTrue(validationResult.HasFailures);
        }
Beispiel #2
0
        public void Validate_ResponseStreamNotAsExpected_OneErrorReturned()
        {
            // Arrange
            const string             fileId          = "fileId";
            MemoryStream             responseStream  = new MemoryStream(Encoding.UTF8.GetBytes("my content"));
            MemoryStream             expectedStream  = new MemoryStream();
            ResponseContentValidator validator       = new ResponseContentValidator(fileId);
            ResourceManagerMock      resourceManager = new ResourceManagerMock {
                { fileId, expectedStream }
            };
            ResponseDataMock responseData = new ResponseDataMock {
                ResponseStream = responseStream
            };

            // Act
            ValidationResult validationResult = validator.Validate(responseData, resourceManager, null);

            // Assert
            Assert.IsNotNull(validationResult.Errors);
            Assert.AreEqual(1, validationResult.Errors.Count());
        }
Beispiel #3
0
        public void Validate_BodyAsExpected_ValidationSucceeds()
        {
            // Arrange
            const string             fileId          = "fileId";
            const string             content         = "my content";
            MemoryStream             responseStream  = new MemoryStream(Encoding.UTF8.GetBytes(content));
            MemoryStream             expectedStream  = new MemoryStream(Encoding.UTF8.GetBytes(content));
            ResponseContentValidator validator       = new ResponseContentValidator(null, content);
            ResourceManagerMock      resourceManager = new ResourceManagerMock {
                { fileId, expectedStream }
            };
            ResponseDataMock responseData = new ResponseDataMock {
                ResponseStream = responseStream
            };

            // Act
            ValidationResult validationResult = validator.Validate(responseData, resourceManager, null);

            // Assert
            Assert.IsFalse(validationResult.HasFailures);
        }