Exemplo n.º 1
0
        public ExtractPagesTests()
        {
            this.persistence      = Substitute.For <ISourcesPersistence>();
            this.sourceRepository = Substitute.For <ISourcesRepository>();
            this.context          = Substitute.For <ISourceContext>();
            this.imageService     = new FakeImageService();
            var matcher = Substitute.For <IUriTemplateMatcher>();

            this.httpMessageHandler = new MockHttpMessageHandler();

            matcher.Match <Brochure>(Arg.Any <Uri>())
            .Returns(new UriTemplateMatches(new Dictionary <string, object>
            {
                { "id", 10 },
            }));

            this.sourceRepository.GetBrochure(Arg.Any <Uri>())
            .Returns(Task.FromResult(new Brochure
            {
                Id = new Uri(SourceId),
            }));

            this.functions = new ExtractPages(
                this.sourceRepository,
                this.imageService,
                matcher,
                this.context,
                this.persistence);

            this.functions.Client = this.httpMessageHandler.ToHttpClient();
        }
 public void Service_should_return_byte_array_that_can_be_converted_to_image()
 {
     var imgService = new FakeImageService(new NoBackgroundInvocation());
     imgService.GetImage(new Uri("http://www.example.com"), (bytes) =>
     {
         var img = Image.FromStream(new MemoryStream(bytes));
         Assert.AreNotEqual(img.Height, 0);
     });
 }
 public void Service_should_return_non_empty_byte_array_for_any_uri()
 {
     var imgService = new FakeImageService(new NoBackgroundInvocation());
     imgService.GetImage(new Uri("http://www.example.com"), (bytes) =>
         {
             Assert.IsNotNull(bytes);
             Assert.IsNotEmpty(bytes);
         });
 }
Exemplo n.º 4
0
        public void Service_should_return_byte_array_that_can_be_converted_to_image()
        {
            var imgService = new FakeImageService(new NoBackgroundInvocation());

            imgService.GetImage(new Uri("http://www.example.com"), (bytes) =>
            {
                var img = Image.FromStream(new MemoryStream(bytes));
                Assert.AreNotEqual(img.Height, 0);
            });
        }
Exemplo n.º 5
0
        public void Service_should_return_non_empty_byte_array_for_any_uri()
        {
            var imgService = new FakeImageService(new NoBackgroundInvocation());

            imgService.GetImage(new Uri("http://www.example.com"), (bytes) =>
            {
                Assert.IsNotNull(bytes);
                Assert.IsNotEmpty(bytes);
            });
        }
        public async Task ChangeProfilePictureWithNonNullPictureUrlShouldReturnOk()
        {
            // Arrange
            const string pictureUrl = "TestPictureUrl";

            var imageService = new FakeImageService();

            var usersController = new UsersController(imageService, null)
                                  .WithTestUser();

            // Act
            var result = await usersController.ChangeProfilePicture(pictureUrl);

            // Assert
            Assert.Equal(pictureUrl, imageService.ImageUrl);
            Assert.Equal(@$ "Images\Users\{TestConstants.TestUsername}", imageService.Destination);
Exemplo n.º 7
0
 public void SetUp()
 {
     fakeImageService = new FakeImageService(new NoBackgroundInvocation());
     service          = new MemoryCachedImageService(fakeImageService);
 }