Пример #1
0
        public void RegisterResponseToXmlTest()
        {
            //Arrange
            RegisterResponse rr = new RegisterResponse(0, new TimeSpan(1,1,1));

            //Act
            byte[] data = rr.GetXmlData();

            //Assert
            Assert.IsNotNull(data);

            Debug.WriteLine(System.Text.Encoding.UTF8.GetString(data));
        }
Пример #2
0
        public void RegisterResponseParseTest()
        {
            //Arrange
            RegisterResponse registerResponse = new RegisterResponse(120, new TimeSpan(12,12,12));
            byte[] data = registerResponse.GetXmlData();

            //Act
            XMLParser parser = new XMLParser(data);

            //Assert
            Assert.IsNotNull(parser);
            Assert.AreEqual(MessageTypes.RegisterResponse, parser.MessageType);
            RegisterResponse result = (RegisterResponse)parser.Message;
            Assert.AreEqual(registerResponse.Id, result.Id);
            Assert.AreEqual(registerResponse.Timeout.Hour, result.Timeout.Hour);
            Assert.AreEqual(registerResponse.Timeout.Minute, result.Timeout.Minute);
            Assert.AreEqual(registerResponse.Timeout.Second, result.Timeout.Second);
            Assert.AreEqual(registerResponse.Timeout.Millisecond, result.Timeout.Millisecond);
        }
Пример #3
0
        public void RegisterResponseConstructorTest()
        {
            //Arrange
            RegisterResponse registerResponse;

            //Act
            registerResponse = new RegisterResponse((ulong)0, new TimeSpan());

            //Assert
            Assert.IsNotNull(registerResponse);
        }
Пример #4
0
        /// <summary>
        /// Rejestracja nowego Computational Node lub Task Manager
        /// </summary>
        /// <param name="obj">Informacje o nowym TM/CN</param>
        /// <returns></returns>
        private RegisterResponse RegisterNewNode(MessageObject obj)
        {
            Register reg = obj as Register;
            RegisterResponse response;

            lock (lockObj)
            {
                switch (reg.Type)
                {
                    case NodeType.TaskManager:
                        TaskManager tm = new TaskManager(reg.SolvableProblems, reg.ParallelThreads);
                        taskManagers.Add(tm);
                        response = new RegisterResponse(tm.Id, timeout);
                        break;

                    case NodeType.ComputationalNode:
                        ComputationalNode cn = new ComputationalNode(reg.SolvableProblems, reg.ParallelThreads);
                        computationalNodes.Add(cn);
                        response = new RegisterResponse(cn.Id, timeout);
                        break;

                    default:
                        response = null;
                        break;
                }
            }

            return response;
        }