public void CharactersDatabaseTest()
        {
            Work(folder =>
            {
                ICharactersDatabase database = new FileDatabase(folder);
                var personsDatabase = (IPersonsDatabase)database;

                var person = new PersonAuthInfo
                {
                    PersonId = Guid.NewGuid()
                };
                personsDatabase.Add(person);

                var character = new Character
                {
                    Id = Guid.NewGuid(),
                    Name = "Нагибатор",
                    Class = CharacterClass.Healer,
                    DeleteTime = DateTime.Now.AddDays(1)
                };
                database.Add(person.PersonId, character);

                var character2 = database.GetCharacter(character.Id);
                Assert.AreEqual(character.Class, character2.Class);

                database.MarkAtDelete(character.Id, DateTime.Now.AddDays(3));
                Assert.IsTrue(database.GetMarkAtDelete(character.Id) > DateTime.Now.AddDays(3).AddMinutes(-1));

                database.CancelDelete(character.Id);
                Assert.IsNull(database.GetMarkAtDelete(character.Id));

                var data1 = new CharacterData
                {
                    Position = new Position { X = 123.45f, Y = 777.77f }
                };
                database.Update(character.Id, data1);
                var data2 = database.GetData(character.Id);
                Assert.AreEqual(data1.Position.X, data2.Position.X);

                data1.Position = new Position { X = 666.66f, Y = 777.77f };
                database.Update(character.Id, data1);
                data2 = database.GetData(character.Id);
                Assert.AreEqual(data1.Position.X, data2.Position.X);
                Assert.AreEqual(data1.Position.Y, data2.Position.Y);
            });
        }
        public void PersonsDatabaseTest()
        {
            Work(folder =>
            {
                IPersonsDatabase database = new FileDatabase(folder);

                Assert.IsNull(database.Search("testUser"));

                var person1 = new PersonAuthInfo
                {
                    PersonId = Guid.NewGuid(),
                    Name = "Ivanov",
                    PasswordHash = "пароль".GetPasswordHash()
                };
                database.Add(person1);
                var person2 = database.Search("Ivanov");
                Assert.AreEqual(person1.PersonId, person2.PersonId);
                Assert.AreEqual(person1.PasswordHash, person2.PasswordHash);

                var session1 = new Session
                {
                    Id = Guid.NewGuid(),
                    PersonId = person1.PersonId,
                    BeginTime = DateTime.Now
                };
                database.AddSession(session1);
                var session2 = database.GetSession(session1.Id);
                Assert.AreEqual(session1.Id, session2.Id);
                Assert.AreEqual(session1.PersonId, session2.PersonId);

                ((Session)session2).EndTime = DateTime.Now.AddHours(1);
                database.UpdateSession(session2);

                var session3 = database.GetSession(session1.Id);
                Assert.AreEqual(session2.EndTime, session3.EndTime);
            });
        }