public async void GetLostDogsSuccessfulForRepoSucess()
        {
            var repo     = new Mock <ILostDogRepository>();
            var security = new Mock <ISecurityService>();

            repo.Setup(o => o.GetLostDogs(It.IsAny <LostDogFilter>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(new RepositoryResponse <List <LostDog>, int>()));
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.True((await service.GetLostDogs(new LostDogFilter(), null, 0, 0)).Successful);
        }
        public async void GetLostDogsDetailsSuccessfulForExistingDog()
        {
            var repo     = new Mock <ILostDogRepository>();
            var security = new Mock <ISecurityService>();

            repo.Setup(o => o.GetLostDogDetails(It.IsAny <int>())).Returns(Task.FromResult(new RepositoryResponse <LostDog>()));
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.True((await service.GetLostDogDetails(1)).Successful);
        }
        public async void DeleteLostDogCommentSuccessfulForSuccessfulResponses()
        {
            var repo     = new Mock <ILostDogRepository>();
            var security = new Mock <ISecurityService>();

            repo.Setup(o => o.DeleteLostDogComment(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(new RepositoryResponse()));
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.True((await service.DeleteLostDogComment(1, 1)).Successful);
        }
        public async void UpdatingLostDogSuccessfulForExistingDogNoPicture()
        {
            var security = new Mock <ISecurityService>();
            var repo     = new Mock <ILostDogRepository>();

            repo.Setup(o => o.UpdateLostDog(It.IsAny <LostDog>())).Returns(Task.FromResult(new RepositoryResponse <LostDog>()));
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.True((await service.UpdateLostDog(new UploadLostDogDto(), null, 1)).Successful);
        }
        public async void MarkLostDogSuccessfulForValidDog()
        {
            var security = new Mock <ISecurityService>();
            var repo     = new Mock <ILostDogRepository>();

            repo.Setup(o => o.MarkDogAsFound(It.IsAny <int>())).Returns(Task.FromResult(new RepositoryResponse()));
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.True((await service.MarkLostDogAsFound(1)).Successful);
        }
        public async void GetLostDogCommentFailsForRepoError()
        {
            var repo     = new Mock <ILostDogRepository>();
            var security = new Mock <ISecurityService>();

            repo.Setup(o => o.GetLostDogComment(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(new RepositoryResponse <LostDogComment>()
            {
                Successful = false
            }));
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.False((await service.GetLostDogComment(1, 1)).Successful);
        }
        public async void AddLostDogCommentSuccessfulForSuccessfulResponses()
        {
            var repo     = new Mock <ILostDogRepository>();
            var security = new Mock <ISecurityService>();

            using var memoryStream = new MemoryStream(new byte[] { 1, 2, 3, 4 });
            var picture = new FormFile(memoryStream, 0, memoryStream.Length, "name", "filename")
            {
                Headers     = new HeaderDictionary(),
                ContentType = "image/jpeg"
            };
            var commentDto = new UploadCommentDto();

            repo.Setup(o => o.AddLostDogComment(It.IsAny <LostDogComment>())).Returns(Task.FromResult(new RepositoryResponse <LostDogComment>()));
            security.Setup(s => s.IsPictureValid(It.IsAny <IFormFile>())).Returns(new ServiceResponse());
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.True((await service.AddLostDogComment(commentDto, picture)).Successful);
        }
        public async void AddLostDogFailsForValidPostDogAndInvalidImage()
        {
            var security = new Mock <ISecurityService>();
            var repo     = new Mock <ILostDogRepository>();
            var picture  = new FormFile(null, 0, 0, "name", "filename");
            var dogDto   = new UploadLostDogDto();
            var dog      = mapper.Map <LostDog>(dogDto);

            repo.Setup(o => o.AddLostDog(dog)).Returns(Task.FromResult(new RepositoryResponse <LostDog>()
            {
                Data = dog
            }));
            security.Setup(s => s.IsPictureValid(It.IsAny <IFormFile>())).Returns((IFormFile f) => new ServiceResponse()
            {
                Successful = false
            });
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.False((await service.AddLostDog(dogDto, null)).Successful);
        }
        public async void UpdatingLostDogFailsForNonExistingDogNewPicture()
        {
            var repo     = new Mock <ILostDogRepository>();
            var security = new Mock <ISecurityService>();

            using var memoryStream = new MemoryStream(new byte[] { 1, 2, 3, 4 });
            var picture = new FormFile(memoryStream, 0, memoryStream.Length, "name", "filename")
            {
                Headers     = new HeaderDictionary(),
                ContentType = "image/jpeg"
            };
            var dogDto = new UploadLostDogDto();

            repo.Setup(o => o.UpdateLostDog(It.IsAny <LostDog>())).Returns(Task.FromResult(new RepositoryResponse <LostDog>()
            {
                Successful = false
            }));
            security.Setup(s => s.IsPictureValid(It.IsAny <IFormFile>())).Returns((IFormFile f) => new ServiceResponse());
            var service = new LostDogService(repo.Object, security.Object, mapper, logger);

            Assert.False((await service.UpdateLostDog(dogDto, picture, 1)).Successful);
        }