示例#1
0
        /// <summary>
        /// Initializes the object of this class. We have chosen to use this method instead of a constructor as various
        /// other methods called from Initilize require a ServerSync.Instance to be set, which requires a construct to
        /// have finished constructing the object already.
        /// </summary>
        public void Initialize()
        {
            localServer   = new LocalServerImpl();
            remoteServers = new Dictionary <Connection, IRemoteServer>();

            domainSync    = new DomainSync();
            worldSync     = new WorldSync();
            componentSync = new ComponentSync();

            localServer.Service.OnNewClient += HandleNewServerConnected;

            ConnectToRemoteServers();

            PluginManager.Instance.AddPluginLoadedHandler("Terminal", RegisterTerminalCommands);
        }
        public void ShouldSendComponentRegistrationUpdates()
        {
            var componentSync = new ComponentSync();

            componentSync.HandleLocalRegisteredComponent(this,
                                                         new RegisteredComponentEventArgs(testComponentDefinition));

            handlers.Verify(h => h.RegisterComponentDefinition(It.Is <ComponentDef>(cd =>
                                                                                    cd.Name == "test" &&
                                                                                    cd.AttributeDefs.Count == 2 &&
                                                                                    cd.AttributeDefs[0].Name == "f" &&
                                                                                    cd.AttributeDefs[0].DefaultValue.Equals(3.14f) &&
                                                                                    cd.AttributeDefs[0].Type == typeof(float).AssemblyQualifiedName &&
                                                                                    cd.AttributeDefs[1].Name == "i" &&
                                                                                    cd.AttributeDefs[1].DefaultValue.Equals(42) &&
                                                                                    cd.AttributeDefs[1].Type == typeof(int).AssemblyQualifiedName)), Times.Once());
        }
        public void ShouldRegisterComponentsWhenReceiveingAnUpdate()
        {
            var componentSync = new ComponentSync();

            componentSync.HandleRemoteRegisteredComponentDefinition(remoteConnectionMock.Object,
                                                                    (ComponentDef)testComponentDefinition);

            componentRegistryMock.Verify(cr => cr.Register(It.Is <ComponentDefinition>(cd =>
                                                                                       cd.Name == "test" &&
                                                                                       cd.AttributeDefinitions.Count == 2 &&
                                                                                       cd.ContainsAttributeDefinition("f") &&
                                                                                       cd["f"].DefaultValue.Equals(3.14f) &&
                                                                                       cd["f"].Type == typeof(float) &&
                                                                                       cd.ContainsAttributeDefinition("i") &&
                                                                                       cd["i"].DefaultValue.Equals(42) &&
                                                                                       cd["i"].Type == typeof(int))), Times.Once());
        }
示例#4
0
        /// <summary>
        /// Initializes the object of this class. We have chosen to use this method instead of a constructor as various
        /// other methods called from Initilize require a ServerSync.Instance to be set, which requires a construct to
        /// have finished constructing the object already.
        /// </summary>
        public void Initialize()
        {
            localServer          = new LocalServerImpl();
            remoteServers        = new Dictionary <Connection, IRemoteServer>();
            AttemptedConnections = new HashSet <Connection>();

            domainSync    = new DomainSync();
            worldSync     = new WorldSync();
            componentSync = new ComponentSync();

            localServer.Service.OnNewClient += HandleNewServerConnected;

            if (ServerDiscovery == null)
            {
                ServerDiscovery = new ConfigDiscovery();
            }

            ConnectToRemoteServers();

            PluginManager.Instance.AddPluginLoadedHandler("Terminal", RegisterTerminalCommands);
        }
        public void ShouldSendComponentRegistrationUpdates()
        {
            var componentSync = new ComponentSync();
            componentSync.HandleLocalRegisteredComponent(this,
                new RegisteredComponentEventArgs(testComponentDefinition));

            handlers.Verify(h => h.RegisterComponentDefinition(It.Is<ComponentDef>(cd =>
                cd.Name == "test" &&
                cd.AttributeDefs.Count == 2 &&
                cd.AttributeDefs[0].Name == "f" &&
                cd.AttributeDefs[0].DefaultValue.Equals(3.14f) &&
                cd.AttributeDefs[0].Type == typeof(float).AssemblyQualifiedName &&
                cd.AttributeDefs[1].Name == "i" &&
                cd.AttributeDefs[1].DefaultValue.Equals(42) &&
                cd.AttributeDefs[1].Type == typeof(int).AssemblyQualifiedName)), Times.Once());
        }
 public void ShouldRegisterComponentSyncAPI()
 {
     var componentSync = new ComponentSync();
     localServiceMock.VerifySet(ls => ls["serverSync.registerComponentDefinition"] = It.IsAny<Delegate>());
 }
        public void ShouldRegisterComponentsWhenReceiveingAnUpdate()
        {
            var componentSync = new ComponentSync();
            componentSync.HandleRemoteRegisteredComponentDefinition(remoteConnectionMock.Object,
                (ComponentDef)testComponentDefinition);

            componentRegistryMock.Verify(cr => cr.Register(It.Is<ComponentDefinition>(cd =>
                cd.Name == "test" &&
                cd.AttributeDefinitions.Count == 2 &&
                cd.ContainsAttributeDefinition("f") &&
                cd["f"].DefaultValue.Equals(3.14f) &&
                cd["f"].Type == typeof(float) &&
                cd.ContainsAttributeDefinition("i") &&
                cd["i"].DefaultValue.Equals(42) &&
                cd["i"].Type == typeof(int))), Times.Once());
        }
        /// <summary>
        /// Initializes the object of this class. We have chosen to use this method instead of a constructor as various
        /// other methods called from Initilize require a ServerSync.Instance to be set, which requires a construct to
        /// have finished constructing the object already.
        /// </summary>
        public void Initialize()
        {
            localServer = new LocalServerImpl();
            remoteServers = new Dictionary<Connection, IRemoteServer>();

            domainSync = new DomainSync();
            worldSync = new WorldSync();
            componentSync = new ComponentSync();

            localServer.Service.OnNewClient += HandleNewServerConnected;

            ConnectToRemoteServers();

            PluginManager.Instance.AddPluginLoadedHandler("Terminal", RegisterTerminalCommands);
        }
        public void ShouldRegisterComponentSyncAPI()
        {
            var componentSync = new ComponentSync();

            localServiceMock.VerifySet(ls => ls["serverSync.registerComponentDefinition"] = It.IsAny <Delegate>());
        }