Esempio n. 1
0
        public void SerializeRegisteredServersTest_ReadOnlyDestination()
        {
            RegisteredServers regServers = new RegisteredServers();

            regServers.ServerGroup    = new ServerGroup[2];
            regServers.ServerGroup[0] = new ServerGroup()
            {
                Name = "Test"
            };
            regServers.ServerGroup[1] = new ServerGroup()
            {
                Name = "Test2"
            };

            string fileName = Path.GetTempFileName();

            File.SetAttributes(fileName, FileAttributes.ReadOnly);
            bool expected = false;
            bool actual;

            actual = RegisteredServerHelper.SerializeRegisteredServers(regServers, fileName);
            Assert.AreEqual(expected, actual);

            File.SetAttributes(fileName, FileAttributes.Normal);
            File.Delete(fileName);
        }
Esempio n. 2
0
        public void SerializeRegisteredServersTest_GoodSerialization()
        {
            RegisteredServers regServers = new RegisteredServers();

            regServers.ServerGroup    = new ServerGroup[2];
            regServers.ServerGroup[0] = new ServerGroup()
            {
                Name = "Test"
            };
            regServers.ServerGroup[1] = new ServerGroup()
            {
                Name = "Test2"
            };

            string fileName = Path.GetTempFileName();
            bool   expected = true;
            bool   actual;

            actual = RegisteredServerHelper.SerializeRegisteredServers(regServers, fileName);
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(File.Exists(fileName));

            string contents    = File.ReadAllText(fileName);
            Regex  regexServer = new Regex("ServerGroup", RegexOptions.None);

            Assert.IsTrue(regexServer.Matches(contents).Count == 2);

            File.Delete(fileName);
        }
Esempio n. 3
0
        public void SerializeRegisteredServersTest_SerializationWithEmptyFileName()
        {
            RegisteredServers regServers = new RegisteredServers();

            string fileName = string.Empty;
            bool   expected = false;
            bool   actual;

            actual = RegisteredServerHelper.SerializeRegisteredServers(regServers, fileName);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void SerializeRegisteredServersTest_SerializationWithNullObject()
        {
            RegisteredServers regServers = null;

            string fileName = Path.GetTempFileName();
            bool   expected = false;
            bool   actual;

            actual = RegisteredServerHelper.SerializeRegisteredServers(regServers, fileName);
            Assert.AreEqual(expected, actual);
        }