示例#1
0
        public void TestPersonAndLogInteractivity()
        {
            var person = new PersonEntity();

            person.Load(new Hashtable {
                { "id", 1 }
            });

            Assert.That(true);

            var logsBefore          = person.GetLogs();
            var mostRecentLogBefore = person.GetMostRecentLog();

            Assert.That(logsBefore.Count == 0);
            Assert.That(mostRecentLogBefore == null);

            var logA = new LogEntity {
                PersonDbId   = person.DbId,
                Action       = "register",
                Client       = "someotherclient 8",
                PollingTable = "8",
                Timestamp    = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds
            };

            logA.Save();

            Assert.That(logA.Exists());

            var logB = new LogEntity {
                PersonDbId   = person.DbId,
                Action       = "unregister",
                Client       = "someotherclient 8",
                PollingTable = "8",
                Timestamp    = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds + 1
            };

            logB.Save();

            Assert.That(logB.Exists());

            var logsAfter          = person.GetLogs();
            var mostRecentLogAfter = person.GetMostRecentLog();

            Assert.That(logsAfter.Count == 2);

            Assert.That(mostRecentLogAfter != null);
            Assert.That(mostRecentLogAfter.Exists());
            Assert.That(mostRecentLogAfter.Action == "unregister");

            logA.Delete();
            logB.Delete();

            Assert.That(!logA.Exists());
            Assert.That(!logB.Exists());
        }