Example #1
0
 public void TestInitialize()
 {
     server = new ServerProgram(settings);
     server.Run();
     server.ExecuteCommand("rnu", new string[] { "Login", "Password", "Name" });
     helper            = new DBHelper(settings);
     DBHelper.Login    = "******";
     DBHelper.Password = "******";
 }
Example #2
0
        public void ExecuteCommandTest(string ip, int port, int clientPort, string command, string[] args, string expectedResult)
        {
            ServerProgram server = new ServerProgram(ip, port, 100);

            server.Run();

            try
            {
                string result = server.ExecuteCommand(command, args);

                Assert.AreEqual(expectedResult, result);
            }
            finally
            {
                Thread.Sleep(server.Stop());
            }
        }
Example #3
0
        public void AutoTimingTest(string name, string text, string newName, string newText)
        {
            SocketSettings.SocketSettings settings = new SocketSettings.SocketSettings("192.168.0.107", 11221, 300);
            ServerProgram server = new ServerProgram(settings);

            server.Run();
            server.ExecuteCommand("rnu", new string[] { "Login", "Password", "Name" });
            DBHelper helper = new DBHelper(settings);

            DBHelper.Login    = "******";
            DBHelper.Password = "******";

            Note note = new Note(name, text, true);

            Thread.Sleep(500);

            Assert.AreEqual(name, note.Name);
            Assert.AreEqual(text, note.Text);
            Assert.IsTrue(DBContext.Notes.Where(x => x.Id == note.Id).Count() == 1);
            ServerRealization.Database.Context.Note dbNote = DBContext.Notes.Where(x => x.Id == note.Id).First();
            Assert.AreEqual(name, dbNote.Name);
            Assert.AreEqual(text, dbNote.Text);
            Assert.IsTrue(new TimeSpan(0, 0, 1) > (note.Created > dbNote.Created ? note.Created - dbNote.Created : dbNote.Created - note.Created));
            Assert.IsTrue(new TimeSpan(0, 0, 1) > (note.LastChanged > dbNote.LastChanged ? note.LastChanged - dbNote.LastChanged : dbNote.LastChanged - note.LastChanged));

            note.Name = newName;
            note.Text = newText;
            Thread.Sleep(7000);
            if (name != newName)
            {
                Assert.AreNotEqual(newName, dbNote.Name);
            }
            if (text != newText)
            {
                Assert.AreNotEqual(newText, dbNote.Text);
            }

            Thread.Sleep(3500);
            Assert.AreEqual(newName, dbNote.Name);
            Assert.AreEqual(newText, dbNote.Text);

            server.Stop();
            Thread.Sleep(1000);
        }
Example #4
0
        public void SimpleTest(string commandName, string[] args, string expectedResult)
        {
            string result = server.ExecuteCommand(commandName, args);

            Assert.AreEqual(expectedResult, result);
        }
Example #5
0
 public void GenerateTestNotes() => server.ExecuteCommand("generate1000notes", new string[] { });