コード例 #1
0
        public async Task DeleteItemAsync()
        {
            var next = new Mock <IDeleteItemService <Uom> >(MockBehavior.Strict);

            next.Setup(n => n.DeleteItemAsync(1001)).Returns(Task.CompletedTask);
            var uut = new DeleteItemService <Uom>(next.Object);
            await uut.DeleteItemAsync(1001);
        }
コード例 #2
0
        public void DeleteItemAsync_Id0()
        {
            var next = new Mock <IDeleteItemService <Uom> >(MockBehavior.Strict).Object;
            var uut  = new DeleteItemService <Uom>(next);

            Assert.ThrowsAsync <ArgumentOutOfRangeException>
            (
                async() => await uut.DeleteItemAsync(0)
            );
        }
コード例 #3
0
        public void DeleteItem_HandlesType_ExpectName()
        {
            //------------Setup for test--------------------------
            var deleteItem = new DeleteItemService();


            //------------Execute Test---------------------------

            //------------Assert Results-------------------------
            Assert.AreEqual("DeleteItemService", deleteItem.HandlesType());
        }
コード例 #4
0
        public void GetAuthorizationContextForService_ShouldReturnContext()
        {
            //------------Setup for test--------------------------
            var service = new DeleteItemService();

            //------------Execute Test---------------------------
            var resId = service.GetAuthorizationContextForService();

            //------------Assert Results-------------------------
            Assert.AreEqual(AuthorizationContext.Contribute, resId);
        }
コード例 #5
0
        public void GetResourceID_ShouldReturnEmptyGuid()
        {
            //------------Setup for test--------------------------
            var service = new DeleteItemService();

            //------------Execute Test---------------------------
            var resId = service.GetResourceID(new Dictionary <string, StringBuilder>());

            //------------Assert Results-------------------------
            Assert.AreEqual(Guid.Empty, resId);
        }
コード例 #6
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);
        }
コード例 #7
0
        public void DeleteItem_CreateServiceEntry_ExpectProperlyFormedDynamicService()
        {
            //------------Setup for test--------------------------
            var deleteItem = new DeleteItemService();


            //------------Execute Test---------------------------
            var a = deleteItem.CreateServiceEntry();
            //------------Assert Results-------------------------
            var b = a.DataListSpecification.ToString();

            Assert.AreEqual("<DataList><itemToAdd ColumnIODirection=\"itemToDelete\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>", b);
        }
コード例 #8
0
        public void deleteItem_CreateServiceEntry_ExpectProperlyFormedDynamicService()
        {
            //------------Setup for test--------------------------
            var deleteItem = new DeleteItemService();


            //------------Execute Test---------------------------
            var a = deleteItem.CreateServiceEntry();
            //------------Assert Results-------------------------
            var b = a.DataListSpecification;

            Assert.AreEqual("<DataList><ResourceType ColumnIODirection=\"Input\"/><Roles ColumnIODirection=\"Input\"/><ResourceName ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>", b);
        }
コード例 #9
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);
        }
コード例 #10
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>()));
        }