public string NodeInfo(dynamic _) { var recdata = this.GetResquetData <NodelInModel>(); try { #region "接口调用验证" //bool flag = DataValidation(recdata.DateTime, recdata.Random, recdata.Sign); //if (!flag) //{ // return this.WriteValidationLog("LoginModule", recdata.DeviceId); //} #endregion NodeBusiness messageBll = new NodeBusiness(); NodeInfoModel info = messageBll.GetNodeInfo(recdata.data.CompCode); if (info != null) { return(this.SendData <NodeInfoModel>(info, "获取经营节点详细成功", ResponseType.Success)); } else { return(this.SendData("获取经营节点列详细为空!", ResponseType.Success)); } } catch (Exception ex) { return(this.WriteExceptionLog("LoginModule", recdata.DeviceId, recdata.DeviceId, "获取经营节点详细异常:" + Json.ToJson(recdata) + "[异常信息:" + ex.Message + "]", "获取经营节点详细异常:" + ex.Message)); } }
public async Task ChangeParent_ParentId_HasValue_PropagateChanges() { //Arrange Node node = new Node { Id = "nodeId", ParentId = "parentId" }; _repositoryMock .Setup(x => x.GetAsync(It.Is <string>(p => p.Equals("nodeId")))) .ReturnsAsync(node); Node parentNode = new Node { Id = "newParentId" }; _repositoryMock .Setup(x => x.GetAsync(It.Is <string>(p => p.Equals("newParentId")))) .ReturnsAsync(parentNode); _workerMock.Setup(x => x.PropagateChanges(It.IsAny <Node>(), It.IsAny <Node>())) .Returns(Task.CompletedTask); var business = new NodeBusiness(_repositoryMock.Object, _workerMock.Object); //Act await business.ChangeParentAsync("nodeId", "newParentId"); //Assert Thread.Sleep(10); _repositoryMock.VerifyAll(); _workerMock.VerifyAll(); }
public async Task ChangeParent_NodeId_Equals_ParentId_Returns() { //Arrange Node node = new Node { Id = "Id" }; _repositoryMock .Setup(x => x.GetAsync(It.IsAny <string>())) .ReturnsAsync(node); Node parentNode = new Node { Id = "Id" }; _repositoryMock .Setup(x => x.GetAsync(It.IsAny <string>())) .ReturnsAsync(parentNode); var business = new NodeBusiness(_repositoryMock.Object, _workerMock.Object); //Act await business.ChangeParentAsync("Id", "Id"); //Assert _repositoryMock.VerifyAll(); }
public void ChangeParent_Null_Parameters_ThrowThrow() { //Arrange var business = new NodeBusiness(_repositoryMock.Object, _workerMock.Object); Func <Task> action1 = async() => await business.ChangeParentAsync(null, "newParentId"); Func <Task> action2 = async() => await business.ChangeParentAsync("parentId", null); //Assert action1.Should().Throw <ArgumentNullException>(); action2.Should().Throw <ArgumentNullException>(); }
public async Task NodeExists_Returns(string id, bool result) { //Arrange _repositoryMock .Setup(x => x.ExistsAsync(It.Is <string>(p => p.Equals(id)))) .ReturnsAsync(result); var business = new NodeBusiness(_repositoryMock.Object, _workerMock.Object); //Act var actionResult = await business.NodeExists(id); //Arrange actionResult.Should().Be(result); }
public void ChangeParent_Node_NotFound_ShouldThrow() { //Arrange Node node = null; _repositoryMock .Setup(x => x.GetAsync(It.Is <string>(p => p.Equals("nodeId")))) .ReturnsAsync(node); var business = new NodeBusiness(_repositoryMock.Object, _workerMock.Object); //Act Func <Task> action = async() => await business.ChangeParentAsync("nodeId", "newParentId"); //Assert action.Should().Throw <ArgumentException>(); _repositoryMock.VerifyAll(); }
public void GetChildren_ReturnsList() { //Arrange _repositoryMock .Setup(x => x.GetAsync(It.IsAny <Expression <Func <Node, bool> > >())) .Returns(new List <Node> { new Node(), new Node() }.AsQueryable()); var business = new NodeBusiness(_repositoryMock.Object, _workerMock.Object); //Act var result = business.GetChildren("nodeId"); //Assert _repositoryMock.VerifyAll(); result.Should().NotBeNullOrEmpty(); result.Should().HaveCount(2); }
public async Task ChangeParent_ParentId_Null_ChangeRoot() { //Arrange Node node = new Node { Id = "nodeId", ParentId = null }; _repositoryMock .Setup(x => x.GetAsync(It.Is <string>(p => p.Equals("nodeId")))) .ReturnsAsync(node); Node parentNode = new Node { Id = "newParentId" }; _repositoryMock .Setup(x => x.GetAsync(It.Is <string>(p => p.Equals("newParentId")))) .ReturnsAsync(parentNode); _repositoryMock .Setup(x => x.GetAsync(It.IsAny <Expression <Func <Node, bool> > >())) .Returns(new List <Node> { new Node() }.AsQueryable()); _workerMock.Setup(x => x.ChangeRoot(It.IsAny <Node>(), It.IsAny <Node>(), It.IsAny <Node>())) .Returns(Task.CompletedTask); var business = new NodeBusiness(_repositoryMock.Object, _workerMock.Object); //Act await business.ChangeParentAsync("nodeId", "newParentId"); //Assert Thread.Sleep(10); _repositoryMock.VerifyAll(); _workerMock.VerifyAll(); }