예제 #1
0
        public void TestScalar()
        {
            var s = @"{
            ""astring"": ""this is a string."",
            ""anint"": 52461,
            ""afloat"": 0.95294,
            ""abool"": false,
            ""anull"": null
        }";

            FConfig d = new FConfig();

            d.LoadString(s);

            Assert.That(d.Get("astring") is string, Is.True);
            Assert.That((string)d.Get("astring"), Is.EqualTo("this is a string."));
            Assert.That(d.GetString("astring"), Is.EqualTo("this is a string."));

            Assert.That(d.Get("anint") is int, Is.True);
            Assert.That((int)d.Get("anint"), Is.EqualTo(52461));
            Assert.That(d.GetInt("anint"), Is.EqualTo(52461));

            Assert.That(d.Get("afloat") is float, Is.True);
            Assert.That((float)d.Get("afloat"), Is.EqualTo(0.95294f));
            Assert.That(d.GetFloat("afloat"), Is.EqualTo(0.95294f));

            Assert.That(d.Get("abool") is bool, Is.True);
            Assert.That((bool)d.Get("abool"), Is.False);
            Assert.That(d.GetBool("abool"), Is.False);

            Assert.That(d.Get("anull"), Is.Null);
        }
예제 #2
0
        public ClientForm()
        {
            InitializeComponent();

            var config = FConfig.LoadFrom("f-config.json");

            textServerName.Text = Environment.MachineName;
            textPort.Text       = config.TcpPort.ToString();

            _myClient = new MyClient(config);

            _controlsToLock = new Control[] {
                textServerName,
                textPort,
                textRemoteFileName,
                textLocalPath,
                buttonList,
                buttonUpload,
                buttonDownload,
                buttonDelete,
                textUserName,
                textPassword,
                buttonBrowse,
                listFiles
            };
        }
예제 #3
0
        public ServerGui()
        {
            InitializeComponent();
            this.FormClosed += formIsClosed;

            var config = FConfig.LoadFrom("f-config.json");

            var log = Logger.New(config);

            log.Info("fserver.gui", config);

            var server = new FServer(log, config);

            textPort.Text       = server.Port.ToString();
            textServerName.Text = server.ServerName;

            _log    = log;
            _server = server;
            _users  = server;

            _controlsToLock = new Control[] {
                textPort,
                textUserName,
                textPassword,
                textFolder,
                buttonList,
                buttonCreate,
                buttonUpdate,
                buttonDelete,
                listUsers
            };
        }
예제 #4
0
        public sbyte[] BuildConfigHash(FConfig config)
        {
            byte[] buffer = serializer.Serialize(config);
            MD5    md5    = MD5.Create();

            byte[]  hash   = md5.ComputeHash(buffer);
            sbyte[] signed = Array.ConvertAll(hash, b => unchecked ((sbyte)b));
            this.ConfigHash = signed;
            return(this.ConfigHash);
        }
예제 #5
0
        private void BTN_Save_Click(object sender, RoutedEventArgs e)
        {
            List <string> acc = new List <string>();

            LSB_FileInclude.Items.OfType <string>().All(x => { acc.Add(x); return(true); });
            FSConfig.Config.FSOptions.FilesInclude = acc.ToList <string>();
            acc = null;

            FConfig.Save();
            this.Close();
        }
예제 #6
0
        public void TestPreparsed()
        {
            var d = new Dictionary <string, object>();

            d["a"] = 1;
            d["b"] = 2;
            d["c"] = 3;
            FConfig c = new FConfig(d);

            Assert.That(c.GetInt("a"), Is.EqualTo(1));
            Assert.That(c.GetInt("b"), Is.EqualTo(2));
            Assert.That(c.GetInt("c"), Is.EqualTo(3));

            // Giving an empty path to Get() should return the root.
            Assert.That(c.Get(""), Is.EqualTo(d));
        }
예제 #7
0
        public void TestDict()
        {
            var     s = @"{
            ""a0"": {
                ""b0"": {
                    ""c0"": 123,
                    ""c1"": 456
                },
                ""b1"": {
                    ""c0"": 789,
                    ""c1"": 012,
                },
                ""b2"": {
                    ""c0"": 345,
                    ""c1"": 678,
                }
            },
            ""a1"": ""hi there!"",
            ""a2"": {
                ""b0"": {
                    ""c0"": 901,
                    ""c1"": 234
                },
                ""b1"": 567,
                ""b2"": {
                    ""c0"": 890,
                    ""c1"": 123,
                }
            }
        }";
            FConfig d = new FConfig();

            d.LoadString(s);

            Assert.That(d.GetInt("a0/b0/c0"), Is.EqualTo(123));
            Assert.That(d.GetInt("a0/b0/c1"), Is.EqualTo(456));
            Assert.That(d.GetInt("a0/b1/c0"), Is.EqualTo(789));
            Assert.That(d.GetInt("a0/b1/c1"), Is.EqualTo(12));
            Assert.That(d.GetInt("a0/b2/c0"), Is.EqualTo(345));
            Assert.That(d.GetInt("a0/b2/c1"), Is.EqualTo(678));
            Assert.That(d.GetString("a1"), Is.EqualTo("hi there!"));
            Assert.That(d.GetInt("a2/b0/c0"), Is.EqualTo(901));
            Assert.That(d.GetInt("a2/b0/c1"), Is.EqualTo(234));
            Assert.That(d.GetInt("a2/b1"), Is.EqualTo(567));
            Assert.That(d.GetInt("a2/b2/c0"), Is.EqualTo(890));
            Assert.That(d.GetInt("a2/b2/c1"), Is.EqualTo(123));
        }
예제 #8
0
        public async Task RunMajorUseCasesWithDummyUser()
        {
            var config = new FConfig()
            {
                TcpPort = 0
            };
            var dummyUsers = new DummyUsers();

            var             fserver = new FServer(Logger.Null, config, dummyUsers);
            IUserManagement users   = fserver;

            await users.Create(_goga);

            await users.Update(_goga);

            var all = await users.List();

            Assert.That(all, Is.Not.Empty);

            var fclient = await FClient.New(config, new ClientInfo {
                ServerName = fserver.ServerName,
                Port       = fserver.Port,
                UserName   = "******",
                Password   = "******"
            });

            await fclient.Upload("f-config.goga.json", "f-config.json");

            await fclient.Upload("NUnit3.TestAdapter.dll.goga", "NUnit3.TestAdapter.dll");

            await fclient.Download("f-config.goga.json", "f-config.copy.json");

            await fclient.Download("NUnit3.TestAdapter.dll.goga", "NUnit3.TestAdapter.dll.copy");

            var list = await fclient.ListFiles();

            Assert.That(list, Is.Not.Empty);

            await fclient.Delete("f-config.goga.json");

            await users.Delete(_goga, false);
        }
예제 #9
0
        public void TestList()
        {
            var     s = @"{
            ""da"": [
                ""a string"",
                ""another one"",
                ""the third in a series""
            ],
            ""db"": [
                { ""a"": 1, ""b"": 2, ""c"": 3 },
                { ""a"": 8, ""b"": 7, ""c"": 6 },
                { ""a"": 4, ""b"": 3, ""c"": 2 },
                { ""a"": 5, ""b"": 6, ""c"": 7 },
            ],
            ""dc"": [
                [ 46, 24, 86, 62 ],
                134.974,
                { ""p"": ""bug"", ""q"": ""lizard"" }
            ]
        }";
            FConfig d = new FConfig();

            d.LoadString(s);

            Assert.That(d.GetString("da/0"), Is.EqualTo("a string"));
            Assert.That(d.GetString("da/1"), Is.EqualTo("another one"));
            Assert.That(d.GetString("da/2"), Is.EqualTo("the third in a series"));

            Assert.That(d.GetInt("db/0/a"), Is.EqualTo(1));
            Assert.That(d.GetInt("db/1/b"), Is.EqualTo(7));
            Assert.That(d.GetInt("db/2/c"), Is.EqualTo(2));
            Assert.That(d.GetInt("db/3/b"), Is.EqualTo(6));

            Assert.That(d.GetInt("dc/0/1"), Is.EqualTo(24));
            Assert.That(d.GetInt("dc/0/3"), Is.EqualTo(62));
            Assert.That(d.GetFloat("dc/1"), Is.EqualTo(134.974f));
            Assert.That(d.GetString("dc/2/p"), Is.EqualTo("bug"));
        }
예제 #10
0
        public void TestVector()
        {
            var s = @"{
            ""a0"": [],
            ""a1"": [ 12 ],
            ""a2"": [ 34.5, 6 ],
            ""a3"": [ 7.89, 0.123, 45 ],
            ""d0"": {},
            ""dx"": { ""x"": 67.8 },
            ""dy"": { ""y"": 9.01 },
            ""dz"": { ""z"": 234.5 },
            ""dxy"": { ""x"": 6.7, ""y"": 901 },
            ""dxz"": { ""z"": 234, ""x"": 567 },
            ""dyz"": { ""y"": 890, ""z"": 123 },
            ""dxyz"": { ""x"": 456, ""y"": 789, ""z"": 0.12 },
        }";

            FConfig d = new FConfig();

            d.LoadString(s);
            Assert.That(d.GetVector("a0"), Is.EqualTo(Vector3.zero));
            Assert.That(d.GetVector("a1"), Is.EqualTo(new Vector3(12, 0, 0)));
            Assert.That(d.GetVector("a2"), Is.EqualTo(new Vector3(34.5f, 6, 0)));
            Assert.That(d.GetVector("a3"), Is.EqualTo(new Vector3(7.89f, 0.123f, 45)));

            Assert.That(d.GetVector("d0"), Is.EqualTo(Vector3.zero));

            Assert.That(d.GetVector("dx"), Is.EqualTo(new Vector3(67.8f, 0, 0)));
            Assert.That(d.GetVector("dy"), Is.EqualTo(new Vector3(0, 9.01f, 0)));
            Assert.That(d.GetVector("dz"), Is.EqualTo(new Vector3(0, 0, 234.5f)));

            Assert.That(d.GetVector("dxy"), Is.EqualTo(new Vector3(6.7f, 901, 0)));
            Assert.That(d.GetVector("dxz"), Is.EqualTo(new Vector3(567, 0, 234)));
            Assert.That(d.GetVector("dyz"), Is.EqualTo(new Vector3(0, 890, 123)));

            Assert.That(d.GetVector("dxyz"), Is.EqualTo(new Vector3(456, 789, 0.12f)));
        }
예제 #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            FConfig fc = new FConfig();

            fc.Visible = true;
        }