コード例 #1
0
        public void DeleteItem_Execute_NullValues_ErrorResult()
        {
            //------------Setup for test--------------------------
            var deleteItem = new DeleteItemService();
            var serializer = new Dev2JsonSerializer();
            //------------Execute Test---------------------------
            StringBuilder             jsonResult = deleteItem.Execute(null, null);
            IExplorerRepositoryResult result     = serializer.Deserialize <IExplorerRepositoryResult>(jsonResult);

            //------------Assert Results-------------------------
            Assert.AreEqual(ExecStatus.Fail, result.Status);
        }
コード例 #2
0
        public void DeleteItem_Execute_ItemToDeleteNotServerExplorerItem_ErrorResult()
        {
            //------------Setup for test--------------------------
            var values = new Dictionary <string, StringBuilder> {
                { "itemToDelete", new StringBuilder("This is not deserializable to ServerExplorerItem") }
            };
            var deleteItem = new DeleteItemService();
            var serializer = new Dev2JsonSerializer();
            //------------Execute Test---------------------------
            StringBuilder             jsonResult = deleteItem.Execute(values, null);
            IExplorerRepositoryResult result     = serializer.Deserialize <IExplorerRepositoryResult>(jsonResult);

            //------------Assert Results-------------------------
            Assert.AreEqual(ExecStatus.Fail, result.Status);
        }
コード例 #3
0
        public void DeleteItem_Execute_ExpectName()
        {
            //------------Setup for test--------------------------
            var deleteItem = new DeleteItemService();

            ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, "");
            var repo = new Mock <IExplorerServerResourceRepository>();
            var ws   = new Mock <IWorkspace>();

            repo.Setup(a => a.DeleteItem(It.IsAny <IExplorerItem>(), It.IsAny <Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Success, "")).Verifiable();

            var serializer = new Dev2JsonSerializer();
            var inputs     = new Dictionary <string, StringBuilder>();

            inputs.Add("itemToDelete", serializer.SerializeToBuilder(item));
            ws.Setup(a => a.ID).Returns(Guid.Empty);
            deleteItem.ServerExplorerRepo = repo.Object;
            //------------Execute Test---------------------------
            deleteItem.Execute(inputs, ws.Object);
            //------------Assert Results-------------------------
            repo.Verify(a => a.DeleteItem(It.IsAny <IExplorerItem>(), It.IsAny <Guid>()));
        }