コード例 #1
0
ファイル: FileDeleteTest.cs プロジェクト: rog1039/crux
        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());
        }
コード例 #2
0
ファイル: FileDeleteTest.cs プロジェクト: rog1039/crux
        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());
        }