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); }
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) ); }
public void DeleteItem_HandlesType_ExpectName() { //------------Setup for test-------------------------- var deleteItem = new DeleteItemService(); //------------Execute Test--------------------------- //------------Assert Results------------------------- Assert.AreEqual("DeleteItemService", deleteItem.HandlesType()); }
public void GetAuthorizationContextForService_ShouldReturnContext() { //------------Setup for test-------------------------- var service = new DeleteItemService(); //------------Execute Test--------------------------- var resId = service.GetAuthorizationContextForService(); //------------Assert Results------------------------- Assert.AreEqual(AuthorizationContext.Contribute, resId); }
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); }
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); }
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); }
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); }
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); }
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>())); }