コード例 #1
0
        public void ToApiMoveNodesRequest()
        {
            // ARRANGE
            ApiMoveNodesRequest expected = FactoryNode.ApiMoveNodesRequest;

            expected.ResolutionStrategy = "overwrite";

            MoveNodesRequest param = new MoveNodesRequest(12,
                                                          new List <MoveNode>(expected.Nodes.Count),
                                                          ResolutionStrategy.Overwrite,
                                                          expected.KeepShareLinks);

            foreach (ApiMoveNode currentApi in expected.Nodes)
            {
                param.NodesToBeMoved.Add(new MoveNode(currentApi.NodeId, currentApi.NewName));
            }

            Mock.Arrange(() => EnumConverter.ConvertResolutionStrategyToValue(param.ResolutionStrategy)).Returns(expected.ResolutionStrategy);

            // ACT
            ApiMoveNodesRequest actual = NodeMapper.ToApiMoveNodesRequest(param);

            // ASSERT
            Assert.Equal(expected, actual, new ApiMoveNodesRequestComparer());
        }
コード例 #2
0
        /// <summary>
        /// Maps a basic property value.
        /// </summary>
        /// <param name="mapping">
        /// The mapping for the property value.  Cannot be null.
        /// </param>
        /// <param name="sourcePropertyType">
        /// The type of the first parameter being supplied to <paramref name="mapping"/>.
        /// Cannot be <c>null</c>.
        /// </param>
        /// <param name="sourcePropertyAlias">
        /// The alias of the node property to map from.  Required.
        /// </param>
        /// <param name="nodeMapper"></param>
        /// <param name="destinationProperty"></param>
        public BasicPropertyMapper(
            Func <object, object> mapping,
            Type sourcePropertyType,
            NodeMapper nodeMapper,
            PropertyInfo destinationProperty,
            string sourcePropertyAlias
            )
            : base(nodeMapper, destinationProperty)
        {
            if (sourcePropertyType == null && mapping != null)
            {
                throw new ArgumentNullException("sourcePropertyType", "Source property type must be specified when using a mapping");
            }

            if (sourcePropertyAlias == null)
            {
                sourcePropertyAlias = NodeMapper.GetPropertyAlias(destinationProperty);

                if (sourcePropertyAlias == null)
                {
                    throw new PropertyAliasNotFoundException(sourcePropertyType, destinationProperty, sourcePropertyAlias);
                }
            }

            SourcePropertyAlias = sourcePropertyAlias;
            RequiresInclude     = false;
            AllowCaching        = true;
            _mapping            = mapping;
            _sourcePropertyType = sourcePropertyType;
        }
コード例 #3
0
 public void GetComplexObject()
 {
     NodeMapper nodeMapper = new NodeMapper();
     Order order= nodeMapper.Get<Order>(14);
     Assert.AreEqual(14, order.Id);
     Assert.AreEqual(2, order.OrderItems.Count);
 }
コード例 #4
0
ファイル: NodeMapper.cs プロジェクト: axandros/SignsInTheSky
    // Start is called before the first frame update
    void Start()
    {
        // Fill in needed components
        lr        = GetComponent <LineRendererToPoint>();
        neighbors = new List <NodeMapper>();

        if (Adjacent != null)
        {
            for (int i = 0; i <= Adjacent.Count; i++)
            {
                NodeMapper nm = Adjacent[i].GetComponent <NodeMapper>();
                if (nm != null)
                {
                    neighbors.Add(nm);
                }
                if (CorrectConnection[i])
                {
                    correctCount++;
                }
            }
        }
        if (SelectSprite != null)
        {
            SelectSprite.enabled = true;
            //selectColor = SelectSprite.material.color;
            DeSelect();
        }
    }
コード例 #5
0
        /// <summary>
        /// Maps a single relationship.
        /// </summary>
        /// <param name="mapping">
        /// Mapping to a nullable node ID.  Takes the context and source property value
        /// as parameters.
        /// If <c>null</c>, the mapping will be deduced from the other parameters.
        /// </param>
        /// <param name="sourcePropertyType">
        /// The type of object being supplied to <paramref name="mapping"/>.
        /// Will be set to <c>int?</c> if <paramref name="mapping"/> is specified.
        /// </param>
        /// <param name="sourcePropertyAlias">
        /// The alias of the node property to map from.  If null, the closest ancestor which is
        /// compatible with <paramref name="destinationProperty"/> will be mapped instead.
        /// </param>
        /// <param name="nodeMapper"></param>
        /// <param name="destinationProperty"></param>
        public SinglePropertyMapper(
            Func <NodeMappingContext, object, int?> mapping,
            Type sourcePropertyType,
            NodeMapper nodeMapper,
            PropertyInfo destinationProperty,
            string sourcePropertyAlias
            )
            : base(nodeMapper, destinationProperty)
        {
            if (sourcePropertyType == null && mapping != null)
            {
                // Default source property type
                sourcePropertyType = typeof(int?);
            }

            if (sourcePropertyAlias == null &&
                mapping != null &&
                !typeof(int?).IsAssignableFrom(sourcePropertyType))
            {
                throw new ArgumentException("If specifying a mapping for a single model with no property alias, the source property type must be assignable to Nullable<int>.");
            }

            SourcePropertyAlias = sourcePropertyAlias;
            RequiresInclude     = true;
            AllowCaching        = true;
            _mapping            = mapping;
            _sourcePropertyType = sourcePropertyType;
        }
コード例 #6
0
        public void ToApiRestorePreviousVersionsRequest()
        {
            // ARRANGE
            string             expectedStrategyValue = "overwrite";
            ResolutionStrategy expectedStrategy      = ResolutionStrategy.Overwrite;

            ApiRestorePreviousVersionsRequest expected = FactoryNode.ApiRestorePreviousVersionsRequest;

            expected.ResolutionStrategy = expectedStrategyValue;

            RestorePreviousVersionsRequest param = new RestorePreviousVersionsRequest(expected.DeletedNodeIds)
            {
                KeepShareLinks     = expected.KeepShareLinks,
                NewParentNodeId    = expected.ParentId,
                ResolutionStrategy = expectedStrategy
            };

            Mock.Arrange(() => EnumConverter.ConvertResolutionStrategyToValue(expectedStrategy)).Returns(expectedStrategyValue);

            // ACT
            ApiRestorePreviousVersionsRequest actual = NodeMapper.ToApiRestorePreviousVersionsRequest(param);

            // ASSERT
            Assert.Equal(expected, actual, new ApiRestorePreviousVersionsRequestComparer());
        }
コード例 #7
0
        public Node EnableRoomEncryption(EnableRoomEncryptionRequest request)
        {
            _client.Executor.CheckApiServerVersion();

            #region Parameter Validation

            request.MustNotNull(nameof(request));
            request.DataRoomRescueKeyPassword.MustNotNullOrEmptyOrWhitespace(nameof(request.DataRoomRescueKeyPassword), true);
            request.Id.MustPositive(nameof(request.Id));

            #endregion

            ApiUserKeyPair apiDataRoomRescueKey = null;
            if (request.DataRoomRescueKeyPassword != null)
            {
                try {
                    UserKeyPair cryptoPair = Crypto.Sdk.Crypto.GenerateUserKeyPair(request.DataRoomRescueKeyPassword);
                    apiDataRoomRescueKey = UserMapper.ToApiUserKeyPair(cryptoPair);
                } catch (CryptoException ce) {
                    DracoonClient.Log.Debug(Logtag, $"Generation of user key pair failed with '{ce.Message}'!");
                    throw new DracoonCryptoException(CryptoErrorMapper.ParseCause(ce), ce);
                }
            }

            ApiEnableRoomEncryptionRequest apiEnableRoomEncryptionRequest =
                RoomMapper.ToApiEnableRoomEncryptionRequest(request, apiDataRoomRescueKey);
            IRestRequest restRequest = _client.Builder.PutEnableRoomEncryption(request.Id, apiEnableRoomEncryptionRequest);
            ApiNode      result      = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PutEnableRoomEncryption);
            return(NodeMapper.FromApiNode(result));
        }
コード例 #8
0
    void SelectUnderCursor()
    {
        NodeMapper node = FindNodeMapperUnderCursor();

        if (node != null)
        {
            if (selectedNode != null)
            {
                if (selectedNode.IsAdjacent(node))
                {
                    selectedNode.ConnectTo(node);
                    DeSelectNode();
                    if (_constellation != null && _constellation.CheckForSuccess())
                    {
                        Debug.Log("Win?");
                        Win();
                    }
                }
                else
                {
                    DeSelectNode();
                }
            }
            else if (selectedNode == null)
            {
                SelectNode(node);
            }
        }
        else
        {
            DeSelectNode();
        }
    }
コード例 #9
0
        public void FromApiDeletedNodeSummary()
        {
            // ARRANGE
            NodeType expectedType      = NodeType.File;
            string   expectedTypeValue = "file";

            RecycleBinItem expected = FactoryNode.RecycleBinItem;

            expected.Type = expectedType;

            ApiDeletedNodeSummary param = new ApiDeletedNodeSummary()
            {
                Type              = expectedTypeValue,
                ParentId          = expected.ParentId,
                ParentPath        = expected.ParentPath,
                Name              = expected.Name,
                FirstDeletedAt    = expected.FirstDeletedAt,
                LastDeletedAt     = expected.LastDeletedAt,
                LastDeletedNodeId = expected.LastDeletedNodeId,
                CntVersions       = expected.VersionsCount
            };

            Mock.Arrange(() => EnumConverter.ConvertValueToNodeTypeEnum(expectedTypeValue)).Returns(expectedType);

            // ACT
            RecycleBinItem actual = NodeMapper.FromApiDeletedNodeSummary(param);

            // ASSERT
            Assert.Equal(expected, actual, new RecycleBinItemComparer());
        }
コード例 #10
0
        /// <summary>
        /// Maps a single relationship.
        /// </summary>
        /// <param name="mapping">
        /// Mapping to a nullable node ID.  Takes the context and source property value
        /// as parameters.
        /// If <c>null</c>, the mapping will be deduced from the other parameters.
        /// </param>
        /// <param name="sourcePropertyType">
        /// The type of object being supplied to <paramref name="mapping"/>.
        /// Will be set to <c>int?</c> if <paramref name="mapping"/> is specified.
        /// </param>
        /// <param name="sourcePropertyAlias">
        /// The alias of the node property to map from.  If null, the closest ancestor which is 
        /// compatible with <paramref name="destinationProperty"/> will be mapped instead.
        /// </param>
        /// <param name="nodeMapper"></param>
        /// <param name="destinationProperty"></param>
        public SinglePropertyMapper(
            Func<NodeMappingContext, object, int?> mapping,
            Type sourcePropertyType,
            NodeMapper nodeMapper,
            PropertyInfo destinationProperty,
            string sourcePropertyAlias
            )
            : base(nodeMapper, destinationProperty)
        {
            if (sourcePropertyType == null && mapping != null)
            {
                // Default source property type
                sourcePropertyType = typeof(int?);
            }
            
            if (sourcePropertyAlias == null
                && mapping != null
                && !typeof(int?).IsAssignableFrom(sourcePropertyType))
            {
                throw new ArgumentException("If specifying a mapping for a single model with no property alias, the source property type must be assignable to Nullable<int>.");
            }

            SourcePropertyAlias = sourcePropertyAlias;
            RequiresInclude = true;
            AllowCaching = true;
            _mapping = mapping;
            _sourcePropertyType = sourcePropertyType;
        }
コード例 #11
0
        public void GetComplexObject()
        {
            NodeMapper nodeMapper = new NodeMapper();
            Order      order      = nodeMapper.Get <Order>(14);

            Assert.AreEqual(14, order.Id);
            Assert.AreEqual(2, order.OrderItems.Count);
        }
コード例 #12
0
 private void DeSelectNode()
 {
     if (selectedNode != null)
     {
         selectedNode.DeSelect();
         selectedNode = null;
     }
 }
コード例 #13
0
    void ClearUnderCursor()
    {
        NodeMapper node = FindNodeMapperUnderCursor();

        if (node != null)
        {
            node.ClearLine();
        }
    }
コード例 #14
0
        public void GetEntityTest()
        {
            NodeMapper mapper = new NodeMapper();
            Person     person = mapper.Get <Person>(7);

            Console.WriteLine("Generated Id: " + person.Id.ToString());
            Assert.AreNotEqual(0, person.Id);
            Assert.AreEqual("Sony", person.FirstName);
        }
コード例 #15
0
        public void FromApiDeletedNodeVersion()
        {
            // ARRANGE
            Classification expectedClassification = Classification.Confidential;
            NodeType       expectedType           = NodeType.File;
            string         expectedTypeValue      = "file";

            PreviousVersion expected = FactoryNode.PreviousVersion;

            expected.Classification = expectedClassification;
            expected.Type           = expectedType;

            ApiDeletedNodeVersion param = new ApiDeletedNodeVersion {
                Type           = expectedTypeValue,
                ParentId       = expected.ParentId,
                ParentPath     = expected.ParentPath,
                Name           = expected.Name,
                AccessedAt     = expected.AccessedAt,
                Classification = (int)expectedClassification,
                CreatedAt      = expected.CreatedAt,
                CreatedBy      = new ApiUserInfo {
                    Id          = expected.CreatedBy.Id.Value,
                    DisplayName = expected.CreatedBy.DisplayName,
                    AvatarUuid  = expected.CreatedBy.AvatarUUID
                },
                DeletedAt = expected.DeletedAt,
                DeletedBy = new ApiUserInfo {
                    Id          = expected.DeletedBy.Id.Value,
                    DisplayName = expected.DeletedBy.DisplayName,
                    AvatarUuid  = expected.DeletedBy.AvatarUUID
                },
                ExpireAt    = expected.ExpireAt,
                Id          = expected.Id,
                IsEncrypted = expected.IsEncrypted,
                Notes       = expected.Notes,
                Size        = expected.Size,
                UpdatedAt   = expected.UpdatedAt,
                UpdatedBy   = new ApiUserInfo {
                    Id          = expected.UpdatedBy.Id.Value,
                    DisplayName = expected.UpdatedBy.DisplayName,
                    AvatarUuid  = expected.UpdatedBy.AvatarUUID
                }
            };

            Mock.Arrange(() => EnumConverter.ConvertValueToNodeTypeEnum(expectedTypeValue)).Returns(expectedType);
            Mock.Arrange(() => EnumConverter.ConvertValueToClassificationEnum((int)expectedClassification)).Returns(expectedClassification);
            Mock.Arrange(() => UserMapper.FromApiUserInfo(param.CreatedBy)).Returns(expected.CreatedBy);
            Mock.Arrange(() => UserMapper.FromApiUserInfo(param.DeletedBy)).Returns(expected.DeletedBy);
            Mock.Arrange(() => UserMapper.FromApiUserInfo(param.UpdatedBy)).Returns(expected.UpdatedBy);

            // ACT
            PreviousVersion actual = NodeMapper.FromApiDeletedNodeVersion(param);

            // ASSERT
            Assert.Equal(expected, actual, new PreviousVersionComparer());
        }
コード例 #16
0
        public ConfigurationManager(NodeMapper nodeMapper, EdgeMapper edgeMapper, BoardConfiguration boardConfiguration,
                                    SerialConfiguration serialConfiguration, GpioConfiguration gpioConfiguration)
        {
            _nodeMapper = nodeMapper;
            _edgeMapper = edgeMapper;

            BoardConfiguration  = boardConfiguration;
            SerialConfiguration = serialConfiguration;
            GpioConfiguration   = gpioConfiguration;
        }
コード例 #17
0
ファイル: NodeMapper.cs プロジェクト: axandros/SignsInTheSky
    public bool IsAdjacentButNotConnecting(NodeMapper nm)
    {
        bool ret   = false;
        int  index = neighbors.IndexOf(nm);

        if (index > -1)
        {
            ret = !(connection == index);
        }
        return(ret);
    }
コード例 #18
0
ファイル: InheritedEntityTest.cs プロジェクト: khoadd/Neo4jD
        public void Get_MyClassEntity_With_Manager()
        {
            NodeMapper nodeMapper = new NodeMapper();
            MyClass    myClaz     = nodeMapper.Get <MyClass>(29);
            Manager    manager    = (Manager)myClaz.SelectedPerson;

            Assert.IsNotNull(myClaz);
            Assert.IsNotNull(manager);
            Assert.AreEqual(29, myClaz.Id);
            Assert.AreEqual("Neo4jD", manager.OfficeName);
        }
コード例 #19
0
        public void DeleteEntityTest()
        {
            Person     person = this.SaveTest();
            NodeMapper mapper = new NodeMapper();

            mapper.Delete <Person>(person);

            Person tryGetDeletedPerson = mapper.Get <Person>(person.Id);

            Assert.AreEqual(person.Id, tryGetDeletedPerson.Id);
        }
コード例 #20
0
        public void FromApiNode_Null()
        {
            // ARRANGE
            Node    expected = null;
            ApiNode param    = null;

            // ACT
            Node actual = NodeMapper.FromApiNode(param);

            // ASSERT
            Assert.Equal(expected, actual, new NodeComparer());
        }
コード例 #21
0
        public Person SaveTest()
        {
            Person person = new Person {
                FirstName = "Sony", LastName = "Arouje"
            };
            NodeMapper mapper = new NodeMapper();

            person = mapper.Save <Person>(person);
            Console.WriteLine("Generated Id: " + person.Id.ToString());
            Assert.AreNotEqual(0, person.Id);
            return(person);
        }
コード例 #22
0
        public void RunSync_UnknownFileSize_Success()
        {
            // ARRANGE
            byte[] fileMock = new byte[1888];
            new Random().NextBytes(fileMock);
            Stream s = new MemoryStream(fileMock);
            IInternalDracoonClient c        = FactoryClients.InternalDracoonClientMock(true);
            FileUploadCallbackMock callback = new FileUploadCallbackMock();
            FileUpload             f        = new FileUpload(c, "id1", FactoryFile.UploadFileRequest, s, -1);

            f.AddFileUploadCallback(callback);
            ApiCreateFileUpload acfu = FactoryFile.ApiCreateFileUpload;

            acfu.Classification = null;
            Mock.Arrange(() => c.Builder.PostCreateFileUpload(Arg.IsAny <ApiCreateFileUpload>())).Returns(FactoryRestSharp.PostCreateFileUploadMock())
            .Occurs(1);
            Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiUploadToken>(Arg.IsAny <IRestRequest>(), RequestType.PostUploadToken, 0))
            .Returns(FactoryFile.ApiUploadToken).Occurs(1);
            Mock.Arrange(() => c.Builder.PutCompleteFileUpload(Arg.AnyString, Arg.IsAny <ApiCompleteFileUpload>()))
            .Returns(FactoryRestSharp.PutCompleteFileUploadMock("path")).Occurs(1);
            Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiNode>(Arg.IsAny <IRestRequest>(), RequestType.PutCompleteUpload, 0))
            .Returns(FactoryNode.ApiNode).Occurs(1);
            Mock.Arrange(() => c.Builder.GetGeneralSettings())
            .Returns(FactoryRestSharp.RestRequestWithAuth(ApiConfig.ApiGetGeneralConfig, Method.GET)).Occurs(1);
            Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiGeneralSettings>(Arg.IsAny <IRestRequest>(), RequestType.GetGeneralSettings, 0))
            .Returns(FactoryServerSettings.ApiGeneralSettings).Occurs(1);
            Mock.Arrange(() => FileMapper.ToApiCreateFileUpload(Arg.IsAny <FileUploadRequest>())).Returns(acfu).Occurs(1);
            Mock.Arrange(() => NodeMapper.FromApiNode(Arg.IsAny <ApiNode>())).Returns(FactoryNode.Node).Occurs(1);
            Mock.Arrange(() => FileHash.CompareFileHashes(Arg.AnyString, Arg.IsAny <byte[]>(), Arg.AnyInt)).Returns(true).OccursAtLeast(1);
            DracoonWebClientExtension wc = Mock.Create <DracoonWebClientExtension>();

            Mock.Arrange(() => Mock.Create <UploadProgressChangedEventArgs>().BytesSent).IgnoreInstance();
            Mock.Arrange(() => c.Executor.ExecuteWebClientChunkUpload(Arg.IsAny <WebClient>(), Arg.IsAny <Uri>(), Arg.IsAny <byte[]>(),
                                                                      RequestType.PostUploadChunk, Arg.IsAny <Thread>(), Arg.AnyInt)).DoInstead(() => Thread.Sleep(250))
            .Raises(() => wc.UploadProgressChanged += null, null, Mock.Create <UploadProgressChangedEventArgs>()).Returns(new byte[13]);
            Mock.Arrange(() => c.Builder.ProvideChunkUploadWebClient(Arg.AnyInt, Arg.AnyLong, Arg.AnyString, Arg.AnyString)).Returns(wc);
            Mock.Arrange(() => JsonConvert.DeserializeObject <ApiUploadChunkResult>(Arg.AnyString)).Returns(FactoryFile.ApiUploadChunkResult);

            Mock.Arrange(() => callback.OnStarted(Arg.AnyString)).Occurs(1);
            Mock.Arrange(() => callback.OnRunning(Arg.AnyString, Arg.AnyLong, Arg.AnyLong)).OccursAtLeast(1);
            Mock.Arrange(() => callback.OnFinished(Arg.AnyString, Arg.IsAny <Node>())).Occurs(1);

            // ACT
            Node actual = f.RunSync();

            s.Close();

            // ASSERT
            Assert.Equal(FactoryNode.Node, actual, new NodeComparer());
            Mock.Assert(callback);
            Mock.Assert(c.Builder);
            Mock.Assert(c.Executor);
        }
コード例 #23
0
        public void FromApiDeletedNodeSummary_Null()
        {
            // ARRANGE
            RecycleBinItem        expected = null;
            ApiDeletedNodeSummary param    = null;

            // ACT
            RecycleBinItem actual = NodeMapper.FromApiDeletedNodeSummary(param);

            // ASSERT
            Assert.Equal(expected, actual, new RecycleBinItemComparer());
        }
コード例 #24
0
        public void RunAsync_IOException()
        {
            // ARRANGE
            byte[] fileMock = new byte[1888];
            new Random().NextBytes(fileMock);
            Stream s = new MemoryStream(fileMock);
            IInternalDracoonClient c        = FactoryClients.InternalDracoonClientMock(true);
            FileUploadCallbackMock callback = new FileUploadCallbackMock();
            FileUpload             f        = new FileUpload(c, "id1", FactoryFile.UploadFileRequest, s, fileMock.Length);

            f.AddFileUploadCallback(callback);
            Mock.Arrange(() => c.Builder.PostCreateFileUpload(Arg.IsAny <ApiCreateFileUpload>())).Returns(FactoryRestSharp.PostCreateFileUploadMock())
            .OnAllThreads();
            Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiUploadToken>(Arg.IsAny <IRestRequest>(), RequestType.PostUploadToken, 0))
            .Returns(FactoryFile.ApiUploadToken).OnAllThreads();
            Mock.Arrange(() => c.Builder.PutCompleteFileUpload(Arg.AnyString, Arg.IsAny <ApiCompleteFileUpload>()))
            .Returns(FactoryRestSharp.PutCompleteFileUploadMock("path")).OnAllThreads();
            Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiNode>(Arg.IsAny <IRestRequest>(), RequestType.PutCompleteUpload, 0))
            .Returns(FactoryNode.ApiNode).OnAllThreads();
            Mock.Arrange(() => c.Builder.GetGeneralSettings())
            .Returns(FactoryRestSharp.RestRequestWithAuth(ApiConfig.ApiGetGeneralConfig, Method.GET)).OnAllThreads();
            Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiGeneralSettings>(Arg.IsAny <IRestRequest>(), RequestType.GetGeneralSettings, 0))
            .Returns(FactoryServerSettings.ApiGeneralSettings).OnAllThreads();
            Mock.Arrange(() => FileMapper.ToApiCreateFileUpload(Arg.IsAny <FileUploadRequest>())).Returns(FactoryFile.ApiCreateFileUpload)
            .OnAllThreads();
            Mock.Arrange(() => NodeMapper.FromApiNode(Arg.IsAny <ApiNode>())).Returns(FactoryNode.Node).OnAllThreads();
            Mock.Arrange(() => FileHash.CompareFileHashes(Arg.AnyString, Arg.IsAny <byte[]>(), Arg.AnyInt)).Returns(true).OnAllThreads();
            DracoonWebClientExtension wc = Mock.Create <DracoonWebClientExtension>();

            Mock.Arrange(() => Mock.Create <UploadProgressChangedEventArgs>().BytesSent).IgnoreInstance().OnAllThreads();
            Mock.Arrange(() => c.Executor.ExecuteWebClientChunkUpload(Arg.IsAny <WebClient>(), Arg.IsAny <Uri>(), Arg.IsAny <byte[]>(),
                                                                      RequestType.PostUploadChunk, Arg.IsAny <Thread>(), Arg.AnyInt))
            .Raises(() => wc.UploadProgressChanged += null, null, Mock.Create <UploadProgressChangedEventArgs>()).Returns(new byte[13])
            .OnAllThreads();
            Mock.Arrange(() => c.Builder.ProvideChunkUploadWebClient(Arg.AnyInt, Arg.AnyLong, Arg.AnyString, Arg.AnyString)).Returns(wc)
            .OnAllThreads();
            Mock.Arrange(() => JsonConvert.DeserializeObject <ApiUploadChunkResult>(Arg.AnyString)).Returns(FactoryFile.ApiUploadChunkResult)
            .OnAllThreads();
            Mock.Arrange(() => s.Read(Arg.IsAny <byte[]>(), Arg.AnyInt, Arg.AnyInt)).Throws(new IOException()).OnAllThreads();
            Mock.Arrange(() => callback.OnStarted(Arg.AnyString)).Occurs(1);
            Mock.Arrange(() => callback.OnFailed(Arg.AnyString, Arg.IsAny <DracoonException>())).Occurs(1);

            // ACT
            f.RunAsync();
            while (f.RunningThread.IsAlive)
            {
            }

            s.Close();

            // ASSERT
            Mock.Assert(callback);
        }
コード例 #25
0
        public void ToApiDeleteNodesRequest()
        {
            // ARRANGE
            ApiDeleteNodesRequest expected = FactoryNode.ApiDeleteNodesRequest;

            DeleteNodesRequest param = new DeleteNodesRequest(expected.NodeIds);

            // ACT
            ApiDeleteNodesRequest actual = NodeMapper.ToApiDeleteNodesRequest(param);

            // ASSERT
            Assert.Equal(expected, actual, new ApiDeleteNodesRequestComparer());
        }
コード例 #26
0
        public void SaveOrder()
        {
            Order order = new Order();
            order.Id = 0;
            order.Name = "Viji";
            order.AddOrderItem(new OrderItem(0, new Product(0, "Rice")));
            order.AddOrderItem(new OrderItem(0, new Product(0, "Sugar")));

            NodeMapper nodeMapper = new NodeMapper();
            nodeMapper.Save<Order>(order);
            Console.WriteLine(order.Id.ToString());
            Assert.AreNotEqual(0, order.Id);
        }
コード例 #27
0
        public void FromApiNodePermissions_Null()
        {
            // ARRANGE
            NodePermissions expected = null;

            ApiNodePermissions param = null;

            // ACT
            NodePermissions actual = NodeMapper.FromApiNodePermissions(param);

            // ASSERT
            Assert.Equal(expected, actual, new NodePermissionsComparer());
        }
コード例 #28
0
        public void FromApiDeletedNodeVersion_Null()
        {
            // ARRANGE
            PreviousVersion expected = null;

            ApiDeletedNodeVersion param = null;

            // ACT
            PreviousVersion actual = NodeMapper.FromApiDeletedNodeVersion(param);

            // ASSERT
            Assert.Equal(expected, actual, new PreviousVersionComparer());
        }
コード例 #29
0
ファイル: NodeMapper.cs プロジェクト: axandros/SignsInTheSky
    public bool IsConnectedTo(NodeMapper nm, out bool adjacent)
    {
        adjacent = false;
        bool ret   = false;
        int  index = neighbors.IndexOf(nm);

        if (index > -1)
        {
            adjacent = true;
            ret      = (index == connection);
        }
        return(ret);
    }
コード例 #30
0
 public void StarReadout()
 {
     for (int i = 0; i < transform.childCount; i++)
     {
         Transform  child = transform.GetChild(i);
         NodeMapper nm    = child.GetComponent <NodeMapper>();
         if (nm != null)
         {
             string str = nm.name + ": " + (nm.IsCorrectConnections() ? "Correct" : "Incorrect");
             Debug.Log(str);
         }
     }
 }
コード例 #31
0
        public void ToApiDeletePreviousVersionsRequest()
        {
            // ARRANGE
            ApiDeletePreviousVersionsRequest expected = FactoryNode.ApiDeletePreviousVersionsRequest;

            DeletePreviousVersionsRequest param = new DeletePreviousVersionsRequest(expected.VersionsToBeDeleted);

            // ACT
            ApiDeletePreviousVersionsRequest actual = NodeMapper.ToApiDeletePreviousVersionsRequest(param);

            // ASSERT
            Assert.Equal(expected, actual, new ApiDeletePreviousVersionsRequestComparer());
        }
コード例 #32
0
        /// <summary>
        /// Maps a collection relationship.
        /// </summary>
        /// <param name="mapping">
        /// Mapping to a collection of node IDs.  Takes the context and source property value
        /// as parameters.  If <c>null</c>, the mapping will be deduced from
        /// the other parameters.
        /// </param>
        /// <param name="sourcePropertyType">
        /// The type of object being supplied to <paramref name="mapping"/>.
        /// Will be set to <c>IEnumerable{int}</c> if <paramref name="mapping"/> is specified.
        /// </param>
        /// <param name="sourcePropertyAlias">
        /// The alias of the node property to map from.  If null, descendants of
        /// the node which are compatible with <paramref name="destinationProperty"/>
        /// will be mapped instead.
        /// </param>
        /// <param name="nodeMapper"></param>
        /// <param name="destinationProperty"></param>
        public CollectionPropertyMapper(
            Func <NodeMappingContext, object, IEnumerable <int> > mapping,
            Type sourcePropertyType,
            NodeMapper nodeMapper,
            PropertyInfo destinationProperty,
            string sourcePropertyAlias
            )
            : base(nodeMapper, destinationProperty)
        {
            if (sourcePropertyType == null && mapping != null)
            {
                sourcePropertyType = typeof(IEnumerable <int>);
            }

            if (sourcePropertyAlias == null &&
                mapping != null &&
                !typeof(IEnumerable <int>).IsAssignableFrom(sourcePropertyType))
            {
                throw new ArgumentException("If specifying a mapping for a collection with no property alias, the source property type must implement IEnumerable<int>.");
            }

            _elementType = destinationProperty.PropertyType.GetGenericArguments().FirstOrDefault();

            if (_elementType == null || !typeof(IEnumerable).IsAssignableFrom(destinationProperty.PropertyType))
            {
                throw new CollectionTypeNotSupportedException(destinationProperty.PropertyType);
            }

            Type rawCollectionType = null;

            if (_elementType == typeof(int))
            {
                // Collection of IDs
                RequiresInclude   = false;
                rawCollectionType = typeof(IEnumerable <int>);
            }
            else
            {
                // Collection of models
                RequiresInclude   = true;
                rawCollectionType = typeof(IEnumerable <>).MakeGenericType(_elementType);
            }

            // See if the collection can be assigned, or must be instantiated
            _canAssignDirectly = CheckCollectionCanBeAssigned(DestinationInfo.PropertyType, rawCollectionType);

            SourcePropertyAlias = sourcePropertyAlias;
            AllowCaching        = true;
            _mapping            = mapping;
            _sourcePropertyType = sourcePropertyType;
        }
コード例 #33
0
        public Node GetNode(long nodeId)
        {
            _client.Executor.CheckApiServerVersion();

            #region Parameter Validation

            nodeId.MustPositive(nameof(nodeId));

            #endregion

            IRestRequest restRequest = _client.Builder.GetNode(nodeId);
            ApiNode      result      = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.GetNode);
            return(NodeMapper.FromApiNode(result));
        }
コード例 #34
0
 public void GetOrder()
 {
     NodeMapper nodeMapper = new NodeMapper();
     Order order = nodeMapper.Get<Order>(19);
     Assert.AreEqual(14, order.Id);
     foreach (OrderItem item in order.OrderItems)
     {
         Console.WriteLine(item.Id.ToString());
         Product prod = item.Product;
         if (prod != null)
             Console.WriteLine(prod.ProductName);
     }
     Assert.AreEqual(2, order.OrderItems.Count);
 }
コード例 #35
0
        /// <summary>
        /// Maps a custom property not covered by the other derivations
        /// of <see cref="PropertyMapperBase"/>.
        /// </summary>
        /// <param name="mapping">
        /// The custom mapping.
        /// </param>
        /// <param name="allowCaching">
        /// Whether the property should allow its mapped value to be cached
        /// and reused.
        /// </param>
        /// <param name="requiresInclude"></param>
        /// <param name="destinationProperty"></param>
        /// <param name="nodeMapper"></param>
        public CustomPropertyMapper(
            CustomPropertyMapping mapping,
            bool requiresInclude,
            bool allowCaching,
            NodeMapper nodeMapper,
            PropertyInfo destinationProperty
            )
            : base(nodeMapper, destinationProperty)
        {
            if (mapping == null)
            {
                throw new ArgumentNullException("mapping");
            }

            RequiresInclude = requiresInclude;
            AllowCaching = allowCaching;
            _mapping = mapping;
        }
コード例 #36
0
        public DefaultPropertyMapper(
            NodeMapper nodeMapper,
            PropertyInfo destinationProperty,
            PropertyInfo nodeProperty,
            Func<object, object> mapping
            )
            :base(nodeMapper, destinationProperty)
        {
            if (nodeProperty == null)
            {
                throw new ArgumentNullException("nodeProperty");
            }

            if (!destinationProperty.PropertyType.IsAssignableFrom(nodeProperty.PropertyType))
            {
                throw new DefaultPropertyTypeException(nodeMapper.DestinationType, destinationProperty, nodeProperty);
            }

            RequiresInclude = false;
            AllowCaching = true;
            _mapping = mapping;
            _nodeProperty = nodeProperty;
        }
コード例 #37
0
 public Person SaveTest()
 {
     Person person = new Person { FirstName = "Sony", LastName="Arouje" };
     NodeMapper mapper = new NodeMapper();
     person=mapper.Save<Person>(person);
     Console.WriteLine("Generated Id: " + person.Id.ToString());
     Assert.AreNotEqual(0, person.Id);
     return person;
 }
コード例 #38
0
        public void DeleteEntityTest()
        {
            Person person = this.SaveTest();
            NodeMapper mapper = new NodeMapper();
            mapper.Delete<Person>(person);

            Person tryGetDeletedPerson = mapper.Get<Person>(person.Id);
            Assert.AreEqual(person.Id, tryGetDeletedPerson.Id);
        }
コード例 #39
0
 public void GetEntityTest()
 {
     NodeMapper mapper = new NodeMapper();
     Person person = mapper.Get<Person>(7);
     Console.WriteLine("Generated Id: " + person.Id.ToString());
     Assert.AreNotEqual(0, person.Id);
     Assert.AreEqual("Sony", person.FirstName);
 }
コード例 #40
0
 public RelationshipCreateHelper(NodeMapper nodeMapper)
 {
     _nodeMapper = nodeMapper;
 }
コード例 #41
0
ファイル: MetaDataMapper.cs プロジェクト: DragonXYZ/cilpe
 internal static void Map(MethodBodyBlock body, MetaDataMapper map)
 {
     NodeMapper mapper = new NodeMapper(map);
     ForEachVisitor.ForEach(body,new ForEachCallback(mapper.Callback));
 }
コード例 #42
0
 public void CanReadNodeToDifferentEntity()
 {
     NodeMapper mapper = new NodeMapper();
     Address address = mapper.Get<Address>(7);
 }