Esempio n. 1
0
        public void TestValidateEulaSigned()
        {
            var workDir = Path.Combine(m_ServHelper.WorkingDir, Guid.NewGuid().ToString());

            var srv1 = new EulaService(workDir, new EulaAttribute("EULA Content"));

            string eulaContent;

            var res1 = srv1.ValidateEulaSigned(out eulaContent);

            CreateEulaFile(workDir, Resources.eula_not_signed);
            var res2 = srv1.ValidateEulaSigned(out eulaContent);

            CreateEulaFile(workDir, Resources.eula_invalid_json);
            var res3 = srv1.ValidateEulaSigned(out eulaContent);

            CreateEulaFile(workDir, Resources.eula_invalid);
            var res4 = srv1.ValidateEulaSigned(out eulaContent);

            CreateEulaFile(workDir, Resources.eula_signed);
            var res5 = srv1.ValidateEulaSigned(out eulaContent);

            Assert.AreEqual("EULA Content", eulaContent);
            Assert.IsFalse(res1);
            Assert.IsFalse(res2);
            Assert.IsFalse(res3);
            Assert.IsFalse(res4);
            Assert.IsTrue(res5);
        }
Esempio n. 2
0
        public void TestInitialization()
        {
            var workDir = Path.Combine(m_ServHelper.WorkingDir, Guid.NewGuid().ToString());

            var srv1 = new EulaService(workDir, new EulaAttribute("EULA Content"));

            Assert.AreEqual("EULA Content", srv1.EulaContent);

            Assert.ThrowsException <EulaContentException>(() => new EulaService(workDir, new EulaAttribute("")));
        }
Esempio n. 3
0
        public void TestSaveEulaConfirmation()
        {
            var workDir = Path.Combine(m_ServHelper.WorkingDir, Guid.NewGuid().ToString());
            var srv1    = new EulaService(workDir, new EulaAttribute("EULA Content"));

            srv1.SaveEulaConfirmation();

            var eulaFile = Path.Combine(workDir, "eula.json");

            Assert.IsTrue(File.Exists(eulaFile));

            EulaAgreementData eula = null;

            using (var file = File.OpenRead(eulaFile))
            {
                eula = JsonSerializer.Deserialize <EulaAgreementData>(file);
            }

            Assert.IsNotNull(eula);
            Assert.IsTrue(eula.IsAgreed);
            Assert.IsTrue(DateTime.Now.Subtract(eula.TimeStamp).TotalSeconds < 3);
        }