Example #1
0
        public async Task FileDeleteLogicFail()
        {
            var data  = new FakeApiDataEntityHandler <VisibleFile>();
            var logic = new FakeApiLogicHandler();
            var cloud = new FakeCloudHandler();

            var model = VisibleData.GetFirst();

            cloud.Result.Setup(m => m.Execute(It.IsAny <DeleteCmd>()))
            .Returns(ActionConfirm.CreateFailure(("Delete Failed")));

            var command = new FileDelete
            {
                DataHandler  = data,
                File         = model,
                CloudHandler = cloud,
                LogicHandler = logic
            };

            await command.Execute();

            cloud.HasExecuted.Should().BeTrue();

            data.HasExecuted.Should().BeFalse();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Delete <VisibleFile> >()), Times.Never());
        }
Example #2
0
        public async Task FileDeleteLogicDoc()
        {
            var data  = new FakeApiDataEntityHandler <VisibleFile>();
            var logic = new FakeApiLogicHandler();
            var cloud = new FakeCloudHandler();

            var model = VisibleData.GetFirst();

            model.IsImage    = false;
            model.IsDocument = true;

            data.Result.Setup(m => m.Execute(It.IsAny <Delete <VisibleFile> >())).Returns(true);
            cloud.Result.Setup(m => m.Execute(It.IsAny <DeleteCmd>()))
            .Returns(ActionConfirm.CreateSuccess("File Loaded"));

            var command = new FileDelete
            {
                DataHandler  = data,
                File         = model,
                CloudHandler = cloud,
                LogicHandler = logic
            };

            await command.Execute();

            cloud.HasExecuted.Should().BeTrue();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Delete <VisibleFile> >()), Times.Once());
        }
Example #3
0
        public async Task VisibleControllerDeleteFailed()
        {
            var data  = new VisibleApiDataHandler();
            var logic = new CoreApiLogicHandler();
            var model = VisibleData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <Loader <VisibleFile> >())).Returns(model);

            logic.Result.Setup(m => m.Execute(It.IsAny <FileDelete>()))
            .Returns(ActionConfirm.CreateFailure("It went wrong"));

            var controller = new VisibleController(data, Cloud, logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Delete(VisibleData.FirstId) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            var check = result.Value as ConfirmViewModel;

            check.Success.Should().BeFalse();

            logic.Result.Verify(s => s.Execute(It.IsAny <FileDelete>()), Times.Once());

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <VisibleFile> >()), Times.Once);
        }
Example #4
0
        protected override void SetupDatabase(IDocumentStore store)
        {
            store.ExecuteIndex(new VisibleIndex());
            store.ExecuteIndex(new FavFanIndex());

            using (var session = store.OpenSession())
            {
                session.Store(VisibleData.GetFirst());
                session.SaveChanges();
            }

            WaitForIndexing(store);
        }
Example #5
0
        public void VisibleMasterTest()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <VisibleFile, VisibleMaster>();
                cfg.CreateMap <VisibleMaster, VisibleFile>();
            });

            var mapper   = new Mapper(config);
            var master   = mapper.Map <VisibleMaster>(VisibleData.GetFirst());
            var document = mapper.Map <VisibleFile>(master);

            master.Should().NotBeNull();
            document.Should().NotBeNull();
            document.IsImage.Should().BeTrue();
            document.IsVideo.Should().BeFalse();
            document.IsDocument.Should().BeFalse();
        }
Example #6
0
        public async Task LoaderControllerUploadSuccess()
        {
            var data  = new VisibleApiDataHandler();
            var logic = new CoreApiLogicHandler();
            var model = VisibleData.GetFirst();

            logic.Result.Setup(m => m.Execute(It.IsAny <ProcessFile>())).Returns(ActionConfirm.CreateSuccess(model));

            var controller = new LoaderController(data, Cloud, logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Upload(VisibleData.GetFile()) as JsonResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <JsonResult>();

            data.HasExecuted.Should().BeFalse();
            logic.HasExecuted.Should().BeTrue();
        }
Example #7
0
        public async Task VisibleControllerDeleteUnauthorized()
        {
            var data  = new VisibleApiDataHandler();
            var model = VisibleData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <Loader <VisibleFile> >())).Returns(model);

            var controller = new VisibleController(data, Cloud, Logic)
            {
                CurrentUser = NonTenantUser
            };
            var result = await controller.Delete(VisibleData.FirstId) as UnauthorizedResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <UnauthorizedResult>();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <VisibleFile> >()), Times.Once);
        }
Example #8
0
        public async Task ProcessImageLogicExists()
        {
            var file = new FakeFile();

            var data  = new FakeApiDataEntityHandler <ImageFile>();
            var logic = new CoreApiLogicHandler();
            var cloud = new FakeCloudHandler();

            var model = VisibleData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <Loader <ImageFile> >())).Returns(model);
            data.Result.Setup(m => m.Execute(It.IsAny <Persist <ImageFile> >())).Returns(model);
            cloud.Result.Setup(m => m.Execute(It.IsAny <UploadCmd>()))
            .Returns(ActionConfirm.CreateSuccess("File Uploaded"));

            var command = new ProcessImage
            {
                DataHandler  = data,
                Source       = file,
                CloudHandler = cloud,
                LogicHandler = logic,
                CurrentUser  = StandardUser,
                Model        = model,
                LoadType     = "test",
                ExistingId   = model.Id
            };

            await command.Execute();

            cloud.HasExecuted.Should().BeTrue();
            cloud.Result.Verify(s => s.Execute(It.IsAny <UploadCmd>()), Times.AtLeastOnce());

            command.Result.Success.Should().BeTrue();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <ImageFile> >()), Times.Once());
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <ImageFile> >()), Times.Once());
        }
Example #9
0
        public async Task CheckProfileImageLogicNoImage()
        {
            var data = new FakeApiDataEntityHandler<ImageFile>();
            var logic = new FakeApiLogicHandler();

            var model = VisibleData.GetFirst();
            var profile = UserData.GetFifth();
            profile.ProfileId = model.Id;

            data.Result.Setup(m => m.Execute(It.IsAny<Loader<ImageFile>>())).Returns(null);

            var command = new CheckProfileImage
            {
                DataHandler = data,
                LogicHandler = logic,
                Model = profile
            };

            await command.Execute();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny<Loader<ImageFile>>()), Times.Once());
        }
Example #10
0
        public async Task ProcessImageLogicMissing()
        {
            var file = new FakeFile()
            {
                FileName = "xxxMissingxxx"
            };

            var data  = new FakeApiDataEntityHandler <ImageFile>();
            var logic = new CoreApiLogicHandler();
            var cloud = new FakeCloudHandler();

            var model = VisibleData.GetFirst();

            var command = new ProcessImage
            {
                DataHandler  = data,
                Source       = file,
                CloudHandler = cloud,
                LogicHandler = logic,
                CurrentUser  = StandardUser,
                Model        = model,
                LoadType     = "test"
            };

            await command.Execute();

            cloud.HasExecuted.Should().BeFalse();
            cloud.Result.Verify(s => s.Execute(It.IsAny <UploadCmd>()), Times.Never());

            command.Result.Success.Should().BeFalse();

            data.HasExecuted.Should().BeFalse();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <ImageFile> >()), Times.Never());
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <ImageFile> >()), Times.Never());
        }